This is the code that i have, but the problem is that, when i click the next link, it didn't go to the page 11-20 and so on...
u know what i mean......
Can you or anyone help on the code??
Thanx!!!
<?
$connection = mysql_connect("host", "user", "password");
mysql_select_db("felix5");
$limit=10;
$Prev = "Previous";
$Next = "Next";
//$numresults=mysql_query("SELECT * FROM artist WHERE keterangan='$id' ORDER BY id ASC");
$numresults=mysql_query("SELECT id,keterangan FROM artist ORDER BY id ASC");
$numrows=mysql_num_rows($numresults);
if (empty($offset)) {
$offset=0;
}
echo "<table width=100% bgcolor=#FFFFFF border=0 cellpadding=2 cellspacing=1>";
$sql = "SELECT id,keterangan FROM artist ORDER BY id ASC limit $offset,$limit ";
$result = mysql_query($sql,$connection) or die("Could not execute query.");
while ($row = mysql_fetch_array($result)) {
echo "
<tr bgcolor=#C0C0C0>
<td align=center><font face=tahoma size=1 color=#000000 size=1><b>$row[id]</b></font></td>
<td><font face=tahoma size=1 color=#000000 size=1><b>$row[keterangan]</b></font></td>
</tr>
";
}
mysql_free_result($result);
echo "</table>";
$pages=intval($numrows/$limit);
$pages1=intval($numrows/$limit);
if ($pages1 > 10) {
$pages=10;
}
else {
$pages=$pages1;
}
if ($numrows%$limit) {
$pages++;
}
if ($offset>1) {
$prevoffset=$offset-$limit;
print "<a href=\"$PHP_SELF?offset=$prevoffset\">$Prev</a> \n";
}
for ($i=1;$i<=$pages;$i++) {
$newoffset=$limit*($i-1);
print "<a href=\"$PHP_SELF?offset=$newoffset\">$i</a> \n";
}
if ($numrows>($offset+$limit)) {
$nextoffset=$offset+$limit;
print "<a href=\"$PHP_SELF?offset=$nextoffset\">$Next</a><p>\n";
}
?>