need prevoius and next links to go to the corresponding reco
Posted: Wed Feb 03, 2010 10:19 am
Hello coders ,
I need the previos and next links to my query like if somebody looking for an item , the item page must have the links for the previuos and next item here iam pasting my query
I need the previos and next links to my query like if somebody looking for an item , the item page must have the links for the previuos and next item here iam pasting my query
Code: Select all
<?
$itemid=$_GET['itemid'];
$page_name="paging.php"; // If you use this code with a different page ( or file ) name then change this
$eu = ($start - 0);
$limit = 10; // No of records to be shown per page.
$that = $eu + $limit;
$back = $eu - $limit;
$next = $eu + $limit;
$query2=" SELECT * FROM items where itemid='$itemid'";
$result2=mysql_query($query2);
echo mysql_error();
$nume=mysql_num_rows($result2);
$bgcolor="#f1f1f1";
echo "<TABLE width=50% align=center cellpadding=0 cellspacing=0> <tr>";
echo "<td bgcolor='dfdfdf' > <font face='arial,verdana,helvetica' color='#000000' size='4'>Name</font></td>";
echo "<td bgcolor='dfdfdf' > <font face='arial,verdana,helvetica' color='#000000' size='4'>Class</font></td>";
echo "<td bgcolor='dfdfdf'> <font face='arial,verdana,helvetica' color='#000000' size='4'>Mark</font></td></tr>";
$query=" SELECT * FROM items where itemid='$itemid limit $eu, $limit ";
$result=mysql_query($query);
echo mysql_error();
while($noticia = mysql_fetch_array($result))
{
if($bgcolor=='#f1f1f1'){$bgcolor='#ffffff';}
else{$bgcolor='#f1f1f1';}
echo "<tr >";
echo "<td align=left bgcolor=$bgcolor id='title'> <font face='Verdana' size='2'>$noticia[itemname]</font></td>";
echo "<td align=left bgcolor=$bgcolor id='title'> <font face='Verdana' size='2'>$noticia[itemid]</font></td>";
echo "<td align=left bgcolor=$bgcolor id='title'> <font face='Verdana' size='2'>$noticia[date]</font></td>";
echo "</tr>";
}
echo "</table>";
echo "<table align = 'center' width='50%'><tr><td align='left' width='30%'>";
if($back >=0) {
print "<a href='$page_name?start=$back'><font face='Verdana' size='2'>PREV</font></a>";
}
echo "</td><td align=center width='30%'>";
$i=0;
$l=1;
for($i=0;$i < $nume;$i=$i+$limit){
if($i <> $eu){
echo " <a href='$page_name?start=$i'><font face='Verdana' size='2'>$l</font></a> ";
}
else { echo "<font face='Verdana' size='4' color=red>$l</font>";} /// Current page is not displayed as link and given font color red
$l=$l+1;
echo "</td><td align='right' width='30%'>";
if($that < $nume) {
print "<a href='$page_name?start=$next'><font face='Verdana' size='2'>NEXT</font></a>";
}
echo "</td></tr></table>";
}
?>