Ryuujin Posted May 23, 2008 Share Posted May 23, 2008 I have this code to show my forum categories: function Template_Main_Categories() { global $db_prefix; // Show the forum categories $result = mysql_query("SELECT * FROM " .$db_prefix. "categories ORDER BY cat_order"); while($row = mysql_fetch_array( $result )) { $cat_id = $row['id']; echo '<div class="Forum_Categories"> <table border="1" width="100%"> <tr> <th colspan="4" class="Table_Header">', $row['cat_name'], '</th> </tr> <tr> <th>Board</th><th>Topics</th><th>Posts</th><th>Last Post</th> </tr>'; $result = mysql_query("SELECT * FROM " .$db_prefix. "forums WHERE cat_parent='$cat_id' ORDER BY forum_order"); while($row = mysql_fetch_array( $result )) { echo '<tr> <td>', $row['forum_name'], '</td><td></td><td></td><td></td> </tr>'; } echo '</table> <br /> </div>'; } } The database has 2 categories and 2 forums. 1 forum for each category, but it is only printing out 1 category. Any ideas? Link to comment https://forums.phpfreaks.com/topic/106876-solved-only-displaying-1-row/ Share on other sites More sharing options...
maxudaskin Posted May 23, 2008 Share Posted May 23, 2008 Put in echo mysql_num_rows($result); then post what it says. Link to comment https://forums.phpfreaks.com/topic/106876-solved-only-displaying-1-row/#findComment-547857 Share on other sites More sharing options...
Ryuujin Posted May 23, 2008 Author Share Posted May 23, 2008 For categories it echoed 2, for forums it echoed 1 :\ Link to comment https://forums.phpfreaks.com/topic/106876-solved-only-displaying-1-row/#findComment-547858 Share on other sites More sharing options...
PFMaBiSmAd Posted May 23, 2008 Share Posted May 23, 2008 You have two nested queries that are both using $result. Pick unique variable names please. Link to comment https://forums.phpfreaks.com/topic/106876-solved-only-displaying-1-row/#findComment-547859 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.