mark25 Posted May 19, 2008 Share Posted May 19, 2008 Let say I have 2 categories and 2 forums in a table(mysql). Table: forums - fid name type order 1 Category1 c 1 2 Forum1 f 1 3 Forum2 f 1 4 Category2 c 2 How can I break each category let say. <table> <tr> <td bgcolor=\"#000000\">Category1</td> </tr> <tr> <td bgcolor=\"#000000\">Forum1</td> </tr> </table> //------ Category 1 ends here ----- <br> //------ New Category ------ <table> <tr> <td bgcolor=\"#000000\">Category2</td> </tr> <tr> <td bgcolor=\"#000000\">Forum2</td> </tr> </table> You have any idea on how can I do this? Link to comment https://forums.phpfreaks.com/topic/106310-category-and-forums-in-one-table/ Share on other sites More sharing options...
947740 Posted May 19, 2008 Share Posted May 19, 2008 I am confused. Do you want to take the data from the database and enter it into the webpage? Link to comment https://forums.phpfreaks.com/topic/106310-category-and-forums-in-one-table/#findComment-544801 Share on other sites More sharing options...
mark25 Posted May 19, 2008 Author Share Posted May 19, 2008 I am confused. Do you want to take the data from the database and enter it into the webpage? Yes. Is there any way I can do it? Most of the php forums can do it? $sql= "SELECT * FROM forums"; $result = $db->query($sql); while($rows = $db->fetch_array($result)){ if($rows['type'] == "c") { $forumcat = "category"; } else { $forumcat = "forum_start"; } eval("\$display = \"".$tp->get("$forumcat")."\";"); // Get template in the database. echo $display; } Link to comment https://forums.phpfreaks.com/topic/106310-category-and-forums-in-one-table/#findComment-544808 Share on other sites More sharing options...
BlueSkyIS Posted May 19, 2008 Share Posted May 19, 2008 using your database structure, how can you tell that forumx belongs in categoryx? I don't see anything creating a relationship between a forum and it's category. Link to comment https://forums.phpfreaks.com/topic/106310-category-and-forums-in-one-table/#findComment-544812 Share on other sites More sharing options...
mark25 Posted May 19, 2008 Author Share Posted May 19, 2008 using your database structure, how can you tell that forumx belongs in categoryx? I don't see anything creating a relationship between a forum and it's category. Oh. lol. I forgot to post it. Table: forums - fid name type order parent 1 Category1 c 1 2 Forum1 f 1 1 3 Forum2 f 1 4 4 Category2 c 2 Any idea how can I do this? Link to comment https://forums.phpfreaks.com/topic/106310-category-and-forums-in-one-table/#findComment-544817 Share on other sites More sharing options...
BlueSkyIS Posted May 19, 2008 Share Posted May 19, 2008 hm, i would have categories in their own table and have a key from forums to the id of the category. then it would be simple to SELECT A.name, B.name FROM categories A, forums B WHERE B.cat_id = A.id GROUP BY B.cat_id ORDER BY A.name Link to comment https://forums.phpfreaks.com/topic/106310-category-and-forums-in-one-table/#findComment-544822 Share on other sites More sharing options...
mark25 Posted May 20, 2008 Author Share Posted May 20, 2008 hm, i would have categories in their own table and have a key from forums to the id of the category. then it would be simple to SELECT A.name, B.name FROM categories A, forums B WHERE B.cat_id = A.id GROUP BY B.cat_id ORDER BY A.name Still you can't line break (br) each categories. . Link to comment https://forums.phpfreaks.com/topic/106310-category-and-forums-in-one-table/#findComment-545472 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.