Page is a not externally linkable
matthewamzn - 8:45 pm on Sep 1, 2008 (gmt 0)
I'm trying to build a php statement that will display my forum's latest threads and attachments. Is there a problem with the while inside another while? It's only bringing up one result.
<?php
$thread_result = mysql_query("SELECT * FROM thread ORDER BY dateline DESC LIMIT 0,25", $connection);
if (!$thread_result) {
die("Database query failed: " . mysql_error());
}
$attach_result = mysql_query("SELECT * FROM attachment", $connection);
if (!$attach_result) {
die("Database query failed: " . mysql_error());
}
while ($thread = mysql_fetch_array($thread_result)) {
if ($thread[22] != 0) {
while ($attach = mysql_fetch_array($attach_result)) {
if ($attach[9] == $thread[2]) {
echo "
<a href=\"showthread.php?t={$thread[0]}\">$thread[1]<br>
<img src=\"attachment.php?attachmentid={$attach[0]}\"></a><br>";
}
}
}
else {
echo "<a href=\"showthread.php?t={$thread[0]}\">$thread[1]<br>";
}
}
?>