I have many results I want just 20 per page, which I have, but when I click next or any other page number they don't load any other esults. Any ideas why please?
If I change $page I see the correct results, so if i change $page=3 then I see the results that I should on page 3. Any ideas how to get it workin with the links?
$limit = 20;
$query_count = "SELECT * FROM directory WHERE authorised = 'Y'";
$result_count = mysql_query($query_count);
$totalrows = mysql_num_rows($result_count);
if(empty($page))
$page = 1;
$limitvalue = $page * $limit - ($limit);
$query = "SELECT * FROM directory WHERE authorised = 'Y' ORDER BY id LIMIT $limitvalue, $limit ";
$result = mysql_query($query);
$count_result = mysql_num_rows($result);
while ($today = mysql_fetch_array($result)){
echo $today['id'];
echo"<br>";
}
// Display links at the top to indicate current page and number of pages displayed
$numofpages = ceil($totalrows / $limit);
echo"<br><p><b>$totalrows</b> result(s)</p>";
$from=$limit*$page-$limit+1;
$to=$from + $count_result-1;
// start 123 next>> table
echo "<table align=\"center\" width=\"90%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr><td width=\"50%\" bgcolor=\"$bg_colour\" align=\"left\">";if($numofpages>1){echo"Showing: $from - $to</td><td width=\"50%\" bgcolor=\"$bg_colour\" align=\"right\"><b>Go to page:</b> ";}
// display previous link if page is not 1
if($page != 1){
$pageprev = $page - 1;
echo("<a href=\"$PHP_SELF?page=$pageprev\"><< PREV</a> ");
}
// display page nos if not 1
for($i = 1; $i <= $numofpages; $i++){
if($numofpages>1){
if($i == $page)
echo(" ".$i." ");
else
echo(" <a href=\"$PHP_SELF?page=$i\">$i</a> ");
}}
// display next page link if there is more than one
if(($totalrows - ($limit * $page)) > 0){
$pagenext = $page + 1;
echo("<a href=\"$PHP_SELF?page=$pagenext\">NEXT >></a>");
}
// end 123 next>> table
echo"</td></tr></table><br>";