Jump to content

Forum Main with Categories


Solar

Recommended Posts

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.