Hey 🙂
I've created a navigation menu that will create a new menu item with each new db table row entry:
$string = safe_query("SELECT * FROM my_table");
echo '<div>
<ul>';
$n=1;
while($abc=mysql_fetch_array($string)) {
$menu_item = ($abc['my_table_entry_name']);
echo '<li><a href="index.php?site=mysite&id='.$abc['my_table_entry_ID'].'"><span>'.$menu_item.'</span></a></li>';
$n++;
}
echo '</ul></div>';
I then have this code to display the information the user selects from the menu:
if(isset($_GET['id'])) $id = (int)$_GET['id'];
$qry = safe_query("SELECT * FROM my_table WHERE my_table_entry_ID='$id'");
while($data=mysql_fetch_array($qry)) {
echo '<!-- content -->';
}
My question is, how may I add a class to the currently selected menu entry?
If I...
echo '<li class="active"><a href="index.php?site=mysite&id='.$abc['my_table_entry_ID'].'"><span>'.$menu_item.'</span></a></li>';
Then the class is obviously going to be added to each menu item. 😕
Thanks for your help.