I have the current code (there maybe a better way to do this but being new this is what I have come up with 🙂 ).
<?php
///Connect To Database
mysql_connect("localhost","username","password");
mysql_select_db("database");
////Main Forum Query////
$results_MainForum = mysql_query("SELECT * FROM ibf_forums WHERE parent_id = 25 ORDER by id ASC");
if (mysql_num_rows($results_MainForum) > "0")
{
while ($row_MainForum = mysql_fetch_array($results_MainForum))
{
$main_forum = $row_MainForum['name'];
$forum_id = $row_MainForum['id'];
////Sub Forum Query////
$results_SubForum = mysql_query("SELECT * FROM ibf_forums WHERE parent_id = $forum_id ORDER by id DESC");
if (mysql_num_rows($results_SubForum) > "0")
{
while ($row_SubForum = mysql_fetch_array($results_SubForum))
{
$subforum_id = $row_SubForum['id'];
$subforum_name = $row_SubForum['name'];
////Article Query////
$results_Articles = mysql_query("SELECT * FROM ibf_topics left join ibf_posts on ibf_topics.tid = ibf_posts.topic_id WHERE ibf_topics.forum_id = $subforum_id ORDER BY ibf_topics.start_date ASC");
if (mysql_num_rows($results_Articles) > "0")
{
while ($row_Articles = mysql_fetch_array($results_Articles))
{
$articles = $row_Articles['title'];
///Print List///
print "$main_forum<br>";
print " $subforum_name<br>";
print " $articles<br>";
}
}
}
}
}
}
?>
I am trying to make a cascading list and for the most part it is working just fine and pulling the info that I want except it is listing the Main and Sub Titles more than one for each article.
This code presents this result
Activism
Florida Road
MA Forrest Association mtg, January 22nd
Activism
Florida Road
testing
Tech Articles
General Tech
Submarining Your Rig
When what I really want is:
Activism
Florida Road
MA Forrest Association mtg, January 22nd
testing
Tech Articles
General Tech
Submarining Your Rig
Any thoughts?
Thanks
Josh