Hello =D
I'm new to this forum, so <?php echo('Hi!'); ?> ;D
ANyway, I've been working on this forum in PHP, and I now want to add seperate forums that have categories inside (like in this forum), but I'm having trouble figuring out a way to call the categories to view while calling the forums to display...for instance, I'm calling from the database to get all of the forums to display, while echoing a function in there that would call all of the categories into the forum.
This is a disgusting rough example of my testing code 🙂
function sub_forums()
{
$sql = "SELECT * FROM `categories` WHERE forum='" . $forum['id'] . "'";
$query = mysql_query($sql) or die(mysql_error());
while ($row = mysql_fetch_array($query)) {
echo ("
<fieldset>
<fieldset>
<a href=\"/cat/" . $row['id'] . "\">" . $row['name'] . "</a>
</fieldset>
" . $row['preview'] . "
</fieldset>
");
}
}
function list_forums()
{
$sql = "SELECT * FROM `forum`";
$query = mysql_query($sql) or die(mysql_error());
$forum = mysql_fetch_array($query);
while ($forum = mysql_fetch_array($query)) {
echo ('
<div class="entry">
<div class="title">
' . $forum['name'] . ' - ' . $forum['id'] . '</a>
</div>
');
echo sub_forums();
echo ('
</div><br />
');
}
}
I hope you see what I'm getting at :S .
To me, it seems easier to try it with a class, but I wanted to see what you guys thought 🙂 .
Anyway, any help would be appreciated 🙂 .