Firefox PHP

Display Last X Posts

Posted by TheChief 
Display Last X Posts
November 25, 2004 11:16AM
I made a small mod to display the last x posts. I dont know, if it is fast, when you have much posts in you phorum.

<?
$posts = 5;

$link = mysql_connect("xxx","xxx","xxx") or die ("Error");
mysql_select_db("phorum") or die("error");

$query = "Select table_name, id from forums";
$result = mysql_query($query) or die("Error");

$i = 1;
while ($row = mysql_fetch_row($result))
{
if ($i == 1)
{
$q1 = "(Select datestamp, subject, author, thread, id from $row[0]) ";
$i =2;
}
else
$q1 = $q1." UNION (Select datestamp, subject, author, thread, id from $row[0])";
}
$q1 = $q1." order by datestamp desc limit $posts";

$result = mysql_query($q1) or die("Error");

echo "<table border=0 WIDTH=100% cellspacing=0>\n";
echo "<tr><td>\n";
echo "<b><u>Last $posts posts</u></b></td></tr>";
while ($row = mysql_fetch_row($result))
{
echo "<tr><td>\n";
echo date("d.m.Y", strtotime($row[0]))." ".$row[1]." from ".$row[2];
echo "</td></tr>\n";
}
echo "</table>";

mysql_free_result($result);
mysql_close($link);
?>
Sorry, you do not have permission to post/reply in this forum.