Hi all... I have asked this question previously, and have made some progress.
Quote from previous post:
Basically, what I now have is a query with a LEFT JOIN, and the lookup table is not used.There are basically three tables in the db:
1) Categories (category name and ID fields) ("iad_sections")
2) Articles (name, id, categoryid) ("iad_entries")
3) lookup table (categoryid, articleid)
Now, I want to be able to create an "archives" page, with a list of all the categories (only about five or so) as headings, each with listing of all the articles in that category underneath
The code I have is as follows:
Now, this half works, but it returnes each of the entries I have in my in iad_entries, along with the title of the category that that entry is assigend to. I also think that my query statment is a lot more verbose than it needs to be, and could be wrong, as I dont understand them completely yet.PHP Code:$sql = "SELECT iad_sections.cat_name AS catName,iad_entries.Title AS entry FROM iad_sections LEFT JOIN iad_entries ON Section=iad_sections.id";
$result =mysql_query($sql);
$numrows=mysql_num_rows($result);
if($numrows==0)
{
print ("No rows found" .mysql_error());
}
else
{
while($row=mysql_fetch_array($result)){
print ("<h2>" .$row['catName'] ."</h2>");
print ("<p>" .$row['entry'].$row['ID'] ."</p>");
}
}
What I need, as posted in my other post, is for the category name to be displayed ONCE, with all the appropriate entry titles listed under each category name.
You can see the result here
Help, as always, much appreciated.







Bookmarks