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!
Dynamic Navigation Menu
Moderator: General Moderators
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:
Basically you're going to need a 'template' of sorts to extract information from your database based on the product/specifications of products.
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 ?>