ryanfilard Posted November 13, 2011 Share Posted November 13, 2011 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> Quote Link to comment https://forums.phpfreaks.com/topic/251077-mysql-menu-issues/ Share on other sites More sharing options...
ryanfilard Posted November 14, 2011 Author Share Posted November 14, 2011 I really need help with this one. Quote Link to comment https://forums.phpfreaks.com/topic/251077-mysql-menu-issues/#findComment-1288107 Share on other sites More sharing options...
PFMaBiSmAd Posted November 14, 2011 Share Posted November 14, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/251077-mysql-menu-issues/#findComment-1288112 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.