Jump to content


Photo

PHP navigation


  • Please log in to reply
5 replies to this topic

#1 norse

norse
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 13 April 2006 - 05:54 AM

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

#2 didier101

didier101
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 13 April 2006 - 06:17 AM

The var in you string would be fetched by $_GET

<?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');
}


#3 norse

norse
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 13 April 2006 - 06:53 AM

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

#4 didier101

didier101
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 13 April 2006 - 07:22 AM

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.

#5 norse

norse
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 13 April 2006 - 08:00 AM

thanks mate its really been a great help.

#6 norse

norse
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 13 April 2006 - 08:19 AM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users