Jump to content

Help with a dynamic menu


kristen

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.