Page 1 of 1

Dynamic Navigation Menu

Posted: Mon May 09, 2005 7:10 pm
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!

Posted: Mon May 09, 2005 7:51 pm
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.

Posted: Tue May 10, 2005 3:48 am
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.