trying to make a forum. the forum is divided into different sections, each section contains different threads, and each thread contains the original post and all it's replies, yadda yadda ... y'all know the drill.
I've got each section containing its own database, with each thread as a table.
when trying to view the section, it's only showing up with the first thread (i.e. the first table in the database).
$username = "username";
$password = "password";
$database = $_GET['which']; // supplied when you click on the section on the main forum page
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die("Unable to select database");
$result=mysql_list_tables($database); // Get list of threads
while ($topicid=mysql_fetch_row($result)) {
echo "",$topicid[0],"<br>"; // test. Show me the thread id.
$query = "SELECT * FROM $topicid[0] WHERE id='0'"; // Select the opening post to view
$topicresult=mysql_query($query);
$row=mysql_fetch_row($topicresult);
echo "",$row[0],"<br>",$row[1],"<br>",$row[2],"<br>",$row[3],"<br>",$row[4],"<br>"; // test. Show me the contents of the post.
$topic = $row[1];
$postwhen = explode(' ',$row[4]);
$postwhendate = $postwhen[0];
$postwhentime = $postwhen[1];
$postbywho = $row[3];
echo "<tr>";
echo "<td width=450 height=40 valign=center align=left>";
if ($d == "TRUE") { // If cookie is set, compare timestamps to generate new post feature.
$threadquery = "SELECT MAX(id) FROM $topicid[0]";
$threadresult=mysql_query($threadquery);
$whichid=mysql_fetch_row($threadresult);
$idquery = "SELECT * FROM $topicid[0] WHERE id='$whichid[0]'";
$idresult=mysql_query($idquery);
$row=mysql_fetch_row($idresult);
$remove = array("-", ":", " ");
$lastpostold = $row[4];
$lastpost = str_replace($remove, "", $lastpostold);
$name = $_COOKIE['srs_membername'];
$forumdb = "forum";
@mysql_select_db($forumdb) or die("Unable to select database");
$whoquery = "SELECT * FROM members WHERE name='$name'";
$whoresult=mysql_query($whoquery);
$whorow=mysql_fetch_row($whoresult);
$whotime = $whorow[4];
$whotimecomp = str_replace($remove, "", $whotime);
if ($whotimecomp < $lastpost) {
echo "<font face=Tahoma size=-2 color=\"yellow\"><b>*NEW POST*</b><br></font>";
}
}
echo "<a href=\"showpost.php?db=",$database,"&post=",$topicid[0],"\" class=\"threads\">",$topic,"</a>";
echo "</td>";
echo "<td width=160 height=40 valign=center align=right>";
echo "<font face=Verdana size=-2 color=\"#ffffff\">",$postwhendate,", ",$postwhentime,"<br>",$postbywho,"</font>";
echo "</td>";
echo "</tr>";
}
mysql_close();
when I echo $topicid, it shows up with the correct values for each table, but for some reason when I query and fetch_row, it will only return the values of the first thread. the second and third come back with nothing.
any ideas why?
P.S. I've granted all priviledges this time =o)