Ok ok, I'm getting there! Just a little help needed.. follow me here!
Forum.php someone sees a list of categories. They click one. They go to forum2.php. It loads the same thing, except whichever one they clicked on "opens up" and drops down to show the sub categories.
Now, I've got forum2.php to where it pulls in the variable you send through the url by clicking the link and calls it $cid.
I've got it to where it pulls in the data from the "forums" table based on that $cid.
I've got it to where it lists the categories as it should, and in the "last post by" colum, it lists the subcategories it pulled from "forums" as it should, put it there for testing.
NOW, what I need is for those forums names to go under the categorie that was clicked on to begin with.. but I'm not sure how to set that loop up.
I beg of you, I'm so close!
Here is the website. You are going to see errors because you are not logged in, at the top of the page. Nevermind those. You'll also see some that show after the forums run out of things to say, but there are still categories listed. You'll see what I mean
Click here, then pick a category, click it, to see what it does: (I suggest movies, to be error free.. same number of rows needed)
http://phases-online.com/phases78/forums/forums.php
here is my code to forums2.php: (the part we're concerned with anyway)
Code:
<?php
require 'db_connect.php';
$cid = $HTTP_GET_VARS['cat_id'];
$query="SELECT * FROM categories ORDER BY cat_order ASC";
$result=mysql_query($query);
$num=mysql_numrows($result);
$query2="SELECT * FROM forums WHERE cat_id=$cid ORDER BY forum_order ASC";
$result2=mysql_query($query2);
$num2=mysql_numrows($result2);
mysql_close();
if ($num==0) {
echo "No Entries.";
} else {
if ($num>25) {
$to=25;
}else{
$to=$num;
}
}
$i=0;
while ($i < $to) {
$cat_id=mysql_result($result,$i,"cat_id");
$cat_title=mysql_result($result,$i,"cat_title");
$forum_id=mysql_result($result2,$i,"forum_id");
$forum_name=mysql_result($result2,$i,"forum_name");
?>
<TR ALIGN="left">
<TD><a href="forums2.php?cat_id=<? echo $cat_id ?>" style="color:#333333;">+</a>
<TD><a href="forums2.php?cat_id=<? echo $cat_id ?>" style="color:#333333;"><? echo $cat_title ?></a>
<TD>10
<TD>100
<TD><? echo $forum_name ?>
<?
$i++;
}
echo "<TR ALIGN='left'>
<TR>
</TABLE>";
?>
Bookmarks