Solar Posted May 25, 2011 Share Posted May 25, 2011 Hello! I've got exactly what I've wanted in my previous topic so I have decided to make a new topic for some help. General General Discussion Description here Entertainment Discussion Description here Gaming Console Discussion Description here Handheld Discussion Description here And a database like this; id title description parent 1 General description here 0 2 Gaming description here 0 3 General Discussion description here 1 4 Entertainment Discussion description here 1 5 Console Discussion description here 2 6 Handheld Discussion description here 2 <?php function generate_forums($parent) { $has_childs = false; global $forums_array; foreach($forums_array as $key => $value) { if ($value['parent'] == $parent) { if ($has_childs === true) { $has_childs = false; } echo '<a href="/category/' . $value['title'] . '/">' . $value['title'] . '</a><br>' . $value['description'] . ''; generate_forums($key); echo '<br>'; } } } generate_forums(0); ?> The code works wonders. But it is hard to customize template wise. $ID#1 $title = General I would start off with <table> I need to have the Categories that Parent = ( 0 ) to have a HTML <tr> I also need the Categories with Parent = ( Value ) to have a HTML <td> Then the tags would be closed off before $ID#2 $title = Gaming's template would start again. I keep trying to scramble the coding around and can't seem to find that probably "simple" touch. Thanks in Advanced. Quote Link to comment https://forums.phpfreaks.com/topic/237462-forum-main-with-categories/ Share on other sites More sharing options...
Solar Posted May 26, 2011 Author Share Posted May 26, 2011 I keep trying and still no luck. I must be missing an if statement somewhere Quote Link to comment https://forums.phpfreaks.com/topic/237462-forum-main-with-categories/#findComment-1220582 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.