Jump to content


This topic is now archived and is closed to further replies.


Adding next> <prev to paging

Recommended Posts

I have a search program that uses simple pagination but I want it to show an option to either go next or prev as well as only showing 4 different pages at a time rather than like 100 options. I don't know if it possible to have it be like ---- next> 1 2 3 4... <previous, when I have a lot more than just the 4 pages. I don't know if that makes a whole lot of sense, but any help would be great.


<table border="1" cellpadding="5" cellspacing="0" bordercolor="#000000">
<td width="60"><b>DT_STRING</b></td>
<td width="100"><b>ACCOUNT</b></td>
<td width="30"><b>ACCOUNT_TYPE</b></td>
<td width="150"><b>CLIENT_ID</b></td>
<td width="150"><b>USER_ID</b></td>


$num = $_GET['num'];
$num = 1;
$limit = 100;
$start = ($num-1)*$limit;
if ($start == 0){
$start = 1;

$metode = $_REQUEST['metode'];
$search = $_REQUEST['search'];
$metode2 = $_REQUEST['metode2'];
$search2 = $_REQUEST['search2'];
$metode3 = $_REQUEST['metode3'];
$search3 = $_REQUEST['search3'];

$query = "SELECT * FROM AUDIT WHERE $metode LIKE '%$search%' AND $metode2 LIKE '%$search2%' AND $metode3 LIKE '%$search3%' ORDER by CLIENT_ID LIMIT $start, $limit";
$result = mysql_query($query);

while ($row = mysql_fetch_array($result)){
//table layout for results

echo ("<tr>");
echo ("<td>$variable1</td>");
echo ("<td>$variable2</td>");
echo ("<td>$variable3</td>");
echo ("<td>$variable4</td>");
echo ("<td>$variable5</td>");
echo ("</tr>");
$totalpages = mysql_num_rows(mysql_query("SELECT * FROM AUDIT WHERE $metode LIKE '%$search%' AND $metode2 LIKE '%$search2%' AND $metode3 LIKE '%$search3%'"));

$totalpages = $totalpages / $limit;

if ($totalpages == round($totalpages,0)) {
$totalpages = round($totalpages,0) ;
}else {
$totalpages = round($totalpages,0) + 1;

$c = 0;
echo "<br>";
$page = ++$c;
echo "[$page] ";
echo "<a href=?num=$page&metode=$metode&search=$search&metode2=$metode2&search2=$search2&metode3=$metode3&search3=$search3>[$page] </a>";

echo "<br>".$totalpages." Pages in total.";


Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.