Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.