How to Paginate Results
Posted: Tue Jul 15, 2003 7:23 am
Hello, I am trying to order my results into pages by limiting the amount of results per page. But I wouldn't have a clue on how to add next and previous page links. This is the Code so far:
Can anyone help me code it so that it creates a previous page and next page link? Thanx
Code: Select all
<?php
print "<table border='0' bgcolor='#CCCCCC' align='center'><tr><td>
<form method=get>
<p>By Route Type:
<select name='search_type'>
<option>SELECT</option>
<option value='2'>Domestic</option>
<option value='3'>International</option>
<option value='1'>Regional</option>
</select>
<font color='#CCCCCC'> </font>
<input name='Searchr3' type='submit' value='Search'>
</form></td></tr></table>";
if ($_GET['search_type'])
{
$sql = "SELECT routes.routeid, depart.depart, depart.departcode, arrive.arrive, arrive.arrivecode
FROM (routes INNER JOIN depart
ON routes.departid = depart.departid)
INNER JOIN arrive ON routes.arriveid = arrive.arriveid
INNER JOIN routetypes ON routes.routetypeid = routetypes.routetypeid
WHERE routetypes.routetypeid = '".$_GET['search_type']."'
LIMIT 0, 20";
$result = mysql_query($sql, $db);
print "<table width='75%' align='center' border=0>";
print "<tr><th><p><b>Route Code</b></th><th><p><b>Departure Airport</b></th><th><p><b>Code</b></th><th><p><b>Arrival Airport</b></th><th><p><b>Code</b></th></tr>";
while
($row = mysql_fetch_array($result)) {
print "<tr bgcolor='$rowcolour'><td align='center'><p>AR".$row['routeid']."</td>";
print "<td align='center'><p>".$row['depart']."</td>";
print "<td align='center'><p>".$row['departcode']."</td>";
print "<td align='center'><p>".$row['arrive']."</td>";
print "<td align='center'><p>".$row['arrivecode']."</td></tr>"; }
print "</table>";
$rowcolour = ($rowcount%2)?$colour1:$colour2;
$rowcount++; }
?>