Hey everyone
I am stuck again :D
This time I'm trying to work with two tables.
First one is a categories one
Second one is an articles one
The category one has the ability to have categories and sub cats too.
So basically I want to list the articles from the article database which have a value of say x for their cat_id field to be listed under their appropriate heading.
So the structure looks a bit like this:
Here is the code which just lists the category titles. I couldn't go on from there :S
any help would be greatly appreciated :D
I am stuck again :D
This time I'm trying to work with two tables.
First one is a categories one
Second one is an articles one
The category one has the ability to have categories and sub cats too.
So basically I want to list the articles from the article database which have a value of say x for their cat_id field to be listed under their appropriate heading.
So the structure looks a bit like this:
Cat
Article
Sub Cat
article
article
Here is the code which just lists the category titles. I couldn't go on from there :S
PHP:
$sql = "SELECT * FROM categories WHERE ParentID = 0 AND id = $id";
$res = mysql_query($sql);
while ($row = mysql_fetch_assoc($res))
{
// if link empty echo cat page else echo link
echo "<dt>$row[name]</dt>";
//echo articles under man cat
$sql_sub = "SELECT * FROM categories WHERE ParentID = ".$row["id"];
//echo $sql_sub;
$res_sub = mysql_query($sql_sub);
while ($row_sub = mysql_fetch_assoc($res_sub))
{
echo "<dd>$row_sub[name]</dd>";
//echo articles under subcat
}
}
any help would be greatly appreciated :D








