Jump to content

Archived

This topic is now archived and is closed to further replies.

norse

PHP navigation

Recommended Posts

Ok this is really a n00b question but i know the answer would be quite easy. But ive tried to google it read some books but no exact explanation and implementation on this one.

Ok here is the problem.

I have a website and some links like

About Us | Contact Us | Home ---> I want to appear in the address bar like index.php?dpage=1 for aboutus and index.php?dpage=2 for contactus

I know ?dpage would be a variable, but can anyone point me in the correct path on how to implement this kind of navigation.

If you can post the exact file structure on this one that would be of great help. Thanks

Share this post


Link to post
Share on other sites
The var in you string would be fetched by $_GET

[code]<?php

switch ($_GET['dpage']) {
  case 1: header('Location: about_us.php'); break;
  case 2: header('Location: contact_us.php'); break;
  default: header('Location: index.php');
}[/code]

Share this post


Link to post
Share on other sites
Yeah thats what im thinking of switch function. But where will i place the switch condition? each of the page? or just in the index file?. Its really helpful mate at least I understand

Share this post


Link to post
Share on other sites
Yeah, put it on your index.php page. So if you want to write an anchor, pointing towards contact.php, you would say index.php?dpage=6 - Then 6 points to contact.php on you index's switch condition.

Share this post


Link to post
Share on other sites
it seems to be working fine but the problem is that its not showing up the index.php file when i pull up index.php its not showing up. and one more thing mate. its not showing in the address bar like index.php?dpage=1 or index.php?dpage=2 i want to show it in the address bar. can you please check this one out

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.