Dynamic Navigation Menu

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
zander213
Forum Newbie
Posts: 13
Joined: Mon Aug 23, 2004 1:46 pm

Dynamic Navigation Menu

Post by zander213 »

Hi Everyone,

I need to build a dynamic menu that will include certain links depending on what variables are in the URL. This is doable - right?

For example: catalog.php?product=widget&color=green

Will have a nav menu like this:

Green Widgets
Brand 1 Green Widget
Brand 2 Green Widget
Brand 3 Green Widget
etc.

Can someone throw me a bone here as to how I can accomplish this. Thanks in advance!
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

we've answered this a number of times on this forum. did you try some searches first?

basically you're going to want to do an if/else if/else or a switch/case to display the information based on your $_GET vars.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

undoubtably you're going to have to have a database. For each products include the links for it in the database, and all that good stuff.

Then when someone calls that particular URL string to their browser, have your page pull that information out of the database.

For example:

Code: Select all

<?
// connect info
if(!$product){ echo "Please select a product."; die(); }
echo $product;

// get links

$query = mysql_query("SELECT link1,link2,link3 FROM table WHERE product = '$product'");

?>
<p>Here are the links for your product.</p>
<a href="<? echo $array['link1']; ?>"><? echo $array['link1']; ?></a><BR>
<a href="<? echo $array['link2']; ?>"><? echo $array['link2']; ?></a><BR>
<a href="<? echo $array['link3']; ?>"><? echo $array['link3']; ?></a><BR>

<? // any other code here ?>
Basically you're going to need a 'template' of sorts to extract information from your database based on the product/specifications of products.
Post Reply