I have a script which pulls the 8 most recent forum posts. I want it to include new topics and thread replies as well. The script that does that is below. Is it possible to add another table for it to do this? OR do i have to put my topics and threads into one table? And identify if a row is a topic or not by an extra field in the table?
Code: Select all
function recent_forum_posts() {
db_connect('lkcforum');
$sql = "SELECT author,subject,tid FROM threads ORDER BY id DESC LIMIT 0, 8";
$result = mysql_query($sql) or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
$subject = $row['subject'];
$tid = $row['tid'];
$author = $row['author'];
if (strlen($subject) > 15) {
$filler = "...";
$subject = substr($subject, 0, 15 - $filler) . $filler;
}
print " <a href=/forums/viewtopic.php?tid=$tid&fid=$fid>$subject</a><br> By: $author";
print "<br><br>";
}
}