ccutla Posted June 1, 2006 Share Posted June 1, 2006 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.php:<center><table border="1" cellpadding="5" cellspacing="0" bordercolor="#000000"><tr><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></tr><tr><td><?php mysql_connect("mysql","root","rootroot");mysql_select_db("AUDITMED");$num = $_GET['num'];if(empty($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)){ $variable1=$row["DT_STRING"]; $variable2=$row["ACCOUNT"]; $variable3=$row["ACCOUNT_TYPE"]; $variable4=$row["CLIENT_ID"]; $variable5=$row["USER_ID"]; //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>";while($c<$totalpages){ $page = ++$c; if($_GET['num']==$page){ echo "[$page] "; }else{//else 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.";?> </table> </center> Quote Link to comment https://forums.phpfreaks.com/topic/10990-adding-next/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.