loony383 Posted November 16, 2007 Share Posted November 16, 2007 Hi i want to select categorys from the table forumtutorial_cats and then it will select forums from forumtutorial_subforums where catid=the catid from the previous query. in a table it would list the category name then all the forums underneith it then it would list the 2nd categorys name and the forums underneith it. it would keep doing thin until it didn't find any more categorys. i am not sure how i would get it to do this. if someone can write me an example of this i would be very greatful. Quote Link to comment Share on other sites More sharing options...
Wes1890 Posted November 16, 2007 Share Posted November 16, 2007 for ($cat=0;$cat<$total_cats;$cat++) { // use mysql here to select all the forums inside of $cat for ($forum=0;$forum<$total_forums;$forum++) { echo $forum; } } that is a basic outline, but thats exactly how you can go about doing it Quote Link to comment Share on other sites More sharing options...
loony383 Posted November 16, 2007 Author Share Posted November 16, 2007 where would i put the query that gets the categorys? Quote Link to comment Share on other sites More sharing options...
Wes1890 Posted November 16, 2007 Share Posted November 16, 2007 grab them (and count how many total) from the DB or whatever your using, before the first FOR statement is made Quote Link to comment Share on other sites More sharing options...
loony383 Posted November 16, 2007 Author Share Posted November 16, 2007 so it would see how many categorys there are then it would go through them doing a seperate query for each category until there are no more to query? Quote Link to comment Share on other sites More sharing options...
Wes1890 Posted November 16, 2007 Share Posted November 16, 2007 ^ yes, but be sure to have an ID field in each category's table-row or else it will be hard to work with the numbers that the FOR statements will be giving out 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.