DionDev
08-04-2008, 09:43 PM
this is some code i use to display topics from a specific forum for a "news" page...
$sql = 'SELECT post.pagetext, thread.*
FROM post AS post, thread AS thread
LEFT JOIN forum AS forum ON (forum.forumid = thread.forumid)
WHERE FIND_IN_SET(4, forum.parentlist) AND post.postid = thread.firstpostid
ORDER BY thread.dateline DESC
LIMIT 5';
$sqlresult = mysql_query($sql) or die(mysql_error());
while ($row = mysql_fetch_array($sqlresult))
{
$subject = $row['title'];
$poster = $row['postusername'];
$posterid = $row['postuserid'];
$time = date("D, M j, Y", $row['dateline']);
$replies = $row['replycount'];
$id = $row['threadid'];
$text = $parser->do_parse($row['pagetext'], true, true, true, true, true, false);
if ($replies == 1)
$replytext = 'reply';
else
$replytext = 'replies';
echo "<b>$subject</b>";
echo '<br>';
echo '<font style="font-size: 8pt;">';
echo "Posted by <a href=\"forums/member.php?u=$posterid\">$poster</a> on $time (<a href=\"forums/showthread.php?t=$id\">$replies $replytext</a>)";
echo '</font>';
echo '<br><br>';
echo $text;
}
this workd, but can anyone think of a more efficient way of doing this?
$sql = 'SELECT post.pagetext, thread.*
FROM post AS post, thread AS thread
LEFT JOIN forum AS forum ON (forum.forumid = thread.forumid)
WHERE FIND_IN_SET(4, forum.parentlist) AND post.postid = thread.firstpostid
ORDER BY thread.dateline DESC
LIMIT 5';
$sqlresult = mysql_query($sql) or die(mysql_error());
while ($row = mysql_fetch_array($sqlresult))
{
$subject = $row['title'];
$poster = $row['postusername'];
$posterid = $row['postuserid'];
$time = date("D, M j, Y", $row['dateline']);
$replies = $row['replycount'];
$id = $row['threadid'];
$text = $parser->do_parse($row['pagetext'], true, true, true, true, true, false);
if ($replies == 1)
$replytext = 'reply';
else
$replytext = 'replies';
echo "<b>$subject</b>";
echo '<br>';
echo '<font style="font-size: 8pt;">';
echo "Posted by <a href=\"forums/member.php?u=$posterid\">$poster</a> on $time (<a href=\"forums/showthread.php?t=$id\">$replies $replytext</a>)";
echo '</font>';
echo '<br><br>';
echo $text;
}
this workd, but can anyone think of a more efficient way of doing this?