Jump to content

MySQL Menu Issues


ryanfilard

Recommended Posts

I am tying to make my category menus mysql based but all my sub categories end up under the last category. Here is my code.

      <ul class="sf-menu">
                            <li><a href="http://www.mysite.com/index.php">Home</a></li>
                            <?PHP do { ?>
                            <li><a href="news.php?c=<?PHP echo $row_bodynav['id']; ?>"><?PHP echo $row_bodynav['catname']; ?></a>
						<?PHP if ($row_bodynav['slug'] == $row_bodynav_sub['parent']) {echo '<ul>'; do { ?><li><a href="news.php?c=<?PHP echo $row_bodynav['id'];?>&sc=<?PHP echo $row_bodynav_sub['id']; ?>"><?PHP echo $row_bodynav_sub['subcatname']; ?></a></li> <?PHP } while ($row_bodynav_sub = mysql_fetch_assoc($bodynav_sub)); echo '</ul>';} ?>
                            </li>
                             
						 <?PHP } while ($row_bodynav = mysql_fetch_assoc($bodynav)); ?>
                             </ul>

Link to comment
Share on other sites

A thread that receives no responses generally indicates a thread that doesn't contain enough information.

 

Your post is missing your queries, sample or real data, and the excepted output.

 

However, I can tell from what you did post that you are executing two queries, when one should be enough, and you are using do/while loops, which take more code to insure that you have data available the first time through the loops, instead of a normal while(){} loop, which fetches the data it needs at the start of each pass through the loop. Your code also contains far too many opening and closing php tags, making it hard to even see what output you are trying to produce.

Link to comment
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.