How to make separate pages?
Posted: Wed Apr 23, 2008 9:32 pm
I have the following booklist.php code, I wana make 10 messages per page, and if more than 10 messages, it should shows "first page", "previous page", "next page", "last page" on the bottom of each page, I was trying to do that, but my code doesn't work for that now, so how would I complish that? can anybody help me?! Thanks!
Code: Select all
<!--booklist.php:Message List---------------------------->
<?php include "search.php"?>
<html>
<head>
<title>Search</title>
</head>
<body>
<?php include "head.html"?>
<table width="68%" border="0">
<tr>
<td>
<?php
$int_page_count=$count; //Total message counts;
$one_page_line=10;
$int_page_num=ceil($int_page_count/$one_page_line);//Total Page;
echo "<font color=#CC33FF>Page:";
for ($i=1;$i<=$int_page_num;$i++)
{
if (isset($_POST["search"]) and isset($_POST["keyword"]) and $_POST["keyword"]!="")
echo "<a href=booklist.php?search=".$_POST["search"]."&keyword=".$_POST["keyword"]."&page=$i>".$i."</a> ";
}
echo "</font>";
if (isset($_POST["search"]) and isset($_POST["keyword"]) and $_POST["keyword"]!="")
{
echo "<br><center>";
echo "Following messages contain key word<font color=red><b>".$_POST["keyword"]."</b></font>Total<font color=red>".$count."</font>messages</center>";
}
?>
</td>
<td><p align=right>Total<font color=red><?echo "$count"?></font>Messages</p></td>
</tr>
</table>
<table width="68%" border="0" align="center">
<?
if (!isset($page) or $page=="")
$page=1;
//$text="";
$begin_line=$int_page_count-($page-1)*$one_page_line;
if ($begin_line<$one_page_line)
$one_page_line=$begin_line;
for ($j=$begin_line;$j>($begin_line-$one_page_line);$j--)
{
echo "<tr><td align=right colspan=2><a href=replylist.php?&recordid=".$Arrid[$j-1].">View Reply</a> <a href=reply.php?task=reply&recordid=".$Arrid[$j-1].">Reply</a> <a href=update.php?recordid=".$Arrid[$j-1].">Edit</a> <a href=delete.php?recordid=".$Arrid[$j-1].">Delete</a> Number<font color=red>$j</font>Message</td></tr>";
print_r ($ArrSearch[$j-1]);
}
?>
</table>
<p align=center><a href="#" onclick=history.back()>Return</a></p>
</body>
</html>