كود PHP:
<?php
//$result1 = $db->sql_query( "SELECT topic_id, forum_id, topic_last_post_id, topic_title, topic_poster, topic_views, topic_replies, topic_moved_id FROM ".$prefix."_bbtopics ORDER BY topic_last_post_id DESC limit 100" );
//while( list( $topic_id, $forum_id, $topic_last_post_id, $topic_title, $topic_poster, $topic_views, $topic_replies, $topic_moved_id ) = sql_fetch_row( $result1, $dbi ) )
echo "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" align=\"center\" width=\"100%\">\n";
//echo"<br>";
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
$max=10; // عدد السجلات في كل صفحة
$from=($max*$page)-$max;
//$sql = mysql_query("select * from ".$prefix."_bbtopics"); // يجب أولاً اختيار جميع السجلات من الجدول
$total = mysql_num_rows(mysql_query("select * from ".$prefix."_bbtopics")); // عدد السجلات جميعها
$result = mysql_query("select * from ".$prefix."_bbtopics ORDER BY topic_last_post_id DESC limit $from,$max"); // اختيار السجلات من المتغير from إلى المتغير max
//$num_sql1 = mysql_num_rows($sql1); // عدد السجلات المحددة
$pages=ceil($num_sql/$max); // عدد الصفحات
while($row = mysql_fetch_assoc($result))
{
echo "<tr>\n<td>\n";
echo "topic number ".$row['topic_id']." has a title ."$row['topic_title'].", it was posted in forum number ".$row['forum_id']."<br />\n";
echo "<a href=\"modules.php?name=Forums&file=viewtopic&t= $topic_id\"><b>$topic_title</b></li></a>";
echo "</td></tr>";
}
echo "<tr>\n<td>\n";
if($page>1) // إذا كانت الصفحة الحالية أكبر من واحد فأكيد فيه صفحات أخرى سابقة
{
$prev=$page-1;
echo"<a href=".$PHP_SELF."?page=$prev> السابق</a>";
}
for($i=1;$i<=$pages;$i++) // حلقة تكرار
{
if($page==$i)
{
echo"[$i]"; // أمر طباعة الصفحة الحالية دون وصلة
else
{
echo"<a href=".$PHP_SELF."?page=$i>$i</a> ";
}
}
if($page<$pages) // إذا كانت الصفحة الحالية أصغر من عدد الصفحات الكلي فأكيد فيه صفحات أخرى تالية
{
$next=$page+1;
echo"<a href=".$PHP_SELF."?page=$next> التالي</a>";
}
echo "</tr>\n</td>\n</table>";
?>