kristen Posted May 5, 2008 Share Posted May 5, 2008 I have a standard left hand menu that is generated from a database. My problem is that I would like the submenu to only show up when it's parent topic is active. For example, when someone is on this page http://www.naccrra.org/membership/, the "Frequently Asked Qs" link should be hidden. Here is the code: <? $query = "SELECT * FROM naccrra_web.site_nav where display = 'Y' and topic = '".$topic."' and level = '1' order by seq"; //echo $query; $result = prod_query($query); $num_rows = mysql_num_rows($result); if ($num_rows!="0") { ?> <ul class="menu"> <? $rawpath = $_SERVER['PHP_SELF']; $pathchunks = explode("/", $rawpath); $folder = $pathchunks[1]; while($row = mysql_fetch_array($result)) { ?> <li><a href="<? echo $row['link']; ?>"<? if ($row['class']!="") { echo " class=".$row['class']; } ?><? if ($row['link']==$path) { echo " class=\"active\""; } ?>><? echo $row['text']; ?></a></li> <? if ($row['has_child']=="Y") { $query2 = "SELECT * FROM naccrra_web.site_nav where topic='".$topic."' and level='2' and parent_id='".$row['id']."' order by seq desc"; //echo $query2; $result2 = prod_query($query2); while($row2 = mysql_fetch_array($result2)) { ?> <ul class="submenu"> <li><a href="<? echo $row2['link']; ?>"<? if ($row2['class']!="") { echo " class=".$row2['class']; } ?><? if ($row2['link']==$path) { echo " class=\"active\""; } ?>><? echo $row2['text']; ?></a></li> </ul> <? } } } ?> </ul> <? } ?> Thanks for any help! Link to comment https://forums.phpfreaks.com/topic/104211-help-with-a-dynamic-menu/ Share on other sites More sharing options...
MadTechie Posted May 5, 2008 Share Posted May 5, 2008 Sounds like a AJAX job, see Dynamic DropDown PHP/AJAX for and example of a drop down you would tweak to do lists Link to comment https://forums.phpfreaks.com/topic/104211-help-with-a-dynamic-menu/#findComment-533500 Share on other sites More sharing options...
kristen Posted May 5, 2008 Author Share Posted May 5, 2008 Thank you, but it's not really what I was looking for. Your code is for a dropdown menu, this is for a navigation menu. Link to comment https://forums.phpfreaks.com/topic/104211-help-with-a-dynamic-menu/#findComment-533508 Share on other sites More sharing options...
MadTechie Posted May 5, 2008 Share Posted May 5, 2008 as i said you could tweak it from lists.. it was just a starting base! Link to comment https://forums.phpfreaks.com/topic/104211-help-with-a-dynamic-menu/#findComment-533521 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.