The Little Guy Posted October 31, 2008 Share Posted October 31, 2008 I'M stumped... My SQL returns all the info I need, the correct way I want it, and it's output would look something like this: category order title 1 0 This is 1 1 2 This is 2 2 0 This is 1 2 1 This is 2 When I do my loop, I need each category in it's own table. So... both category 1 rows need to be in one table and both category 2 rows need to be in a second table. both tables will look exactly the same, but some tables may have one row and others can have more Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted October 31, 2008 Share Posted October 31, 2008 Post your existing code here. Should be able to adapt your existing code for what you want Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted October 31, 2008 Author Share Posted October 31, 2008 while($row = mysql_fetch_array($sql)){ echo '<table class="mainTable">'; echo'<tr> <th class="categoryTitle" colspan="2">'.$row['category'].'</th> <th>Topics</th> <th>Posts</th> </tr>'; echo'<tr> <td class="boardUpdate"> <img src="" /> </td> <td class="boardTitle"> <p><a class="bold" href="board.php?id='.$row['bid'].'">'.$row['title'].'</a> <p>'.$row['description'].'</p> </td> <td class="boardTopics"> <p>'.$row['topicCount'].'</p> </td> <td class="boardPosts"> <p>'.$row['postCount'].'</p> </td> <td class="boardLastInfo"> <p>Last Post Info</p> </td> </tr>'; echo '</table>'; } The current Result: http://dudeel.com/forums/ The first two should be in one table, the next three in a second table and the last one should be by its self. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted October 31, 2008 Share Posted October 31, 2008 $prevCat = null; while($row = mysql_fetch_array($sql)) { if($prevCat != $row['category']) { echo '<table class="mainTable">'; echo'<tr> <th class="categoryTitle" colspan="2">'.$row['category'].'</th> <th>Topics</th> <th>Posts</th> </tr>'; $prevCat = $row['category']; } echo'<tr> <td class="boardUpdate"> <img src="" /> </td> <td class="boardTitle"> <p><a class="bold" href="board.php?id='.$row['bid'].'">'.$row['title'].'</a> <p>'.$row['description'].'</p> </td> <td class="boardTopics"> <p>'.$row['topicCount'].'</p> </td> <td class="boardPosts"> <p>'.$row['postCount'].'</p> </td> <td class="boardLastInfo"> <p>Last Post Info</p> </td> </tr>'; if($prevCat != $row['category']) { echo '</table>'; } } Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted October 31, 2008 Author Share Posted October 31, 2008 Lovely Thank You! Quote Link to comment 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.