hello... Im not sure what im doing wrong exactly.. but when i click next it will say 20 30 etc in the browser address but it won't show the correct items... it shows the same as the first page even though there is only 25 records.. heres my code -
<?php include "header.php";?>
<?php
@ $db = mysql_pconnect($mysql['host'], $mysql['user'], $mysql['pass']);
if (!$db)
{
die("error");
}
mysql_select_db($mysql['db']);
$query = "SELECT * FROM images LIMIT 0, 10";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
for ($i = 0; $i < $num_results; $i++)
{
$row = mysql_fetch_array($result);
$id = $row['id'];
echo '<img src="uploads/' . $id . '" border="1"><br>';
}
if (!isset($_GET['startrow']) or !is_numeric($_GET['startrow'])) {
$startrow = 0;
} else {
$startrow = (int)$_GET['startrow'];
}
$fetch = mysql_query("SELECT * FROM images LIMIT $startrow, 10")or
die(mysql_error());
echo '<a href="'.$_SERVER['PHP_SELF'].'?startrow='.($startrow+10).'">Next</a>';
$prev = $startrow - 10;
if ($prev >= 0)
echo '<a href="'.$_SERVER['PHP_SELF'].'?startrow='.$prev.'">Previous</a>';
?>
<?
include "footer.php";
?>
Any pointers would greatly be appreciated.