Hi Guys
Im trying to get the following snippet to work, it displays the first 5 results as per the $limit var & displays the correct number of pages for the results
PREV5 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 NEXT5
but when i click NEXT5 or any other of the pages the results remain on the 1st page, can anyone help please ??
<?php
require('config.php');
@mysql_connect('localhost', '$username', '$password') or die("ERROR--CAN'T CONNECT TO SERVER");
@mysql_select_db($database) or die("ERROR--CAN'T CONNECT TO DB");
$limit = 5;
$query_count = "SELECT * FROM details";
$result_count = mysql_query($query_count);
$totalrows = mysql_num_rows($result_count);
if(empty($page)){
$page = 1;
}
$limitvalue = $page * $limit - ($limit);
$query = "SELECT * FROM details LIMIT $limitvalue, $limit";
$result = mysql_query($query) or die("Error: " . mysql_error());
if(mysql_num_rows($result) == 0){
echo("Nothing to Display!");
}
echo("<table>");
while($row = mysql_fetch_array($result)){
echo($row["id"]);
echo("<td></tr>");
echo($row["first"]);
echo("</td>n</tr>");
}
echo("</table>");
if($page != 1){
$pageprev = $page--;
echo("<a href=\"page.php&page=$pageprev\">PREV".$limit."</a> ");
}else{
echo("PREV".$limit." ");
}
$numofpages = $totalrows / $limit;
for($i = 1; $i <= $numofpages; $i++){
if($i == $page){
echo($i." ");
}else{
echo("<a href=\"page.php?page=$i\">$i</a> ");
}
}
if(($totalrows % $limit) != 0){
if($i == $page){
echo($i." ");
}else{
echo("<a href=\"page.php?page=$i\">$i</a> ");
}
}
if(($totalrows - ($limit * $page)) > 0){
$pagenext = $page++;
echo("<a href=\"page.php?page=$pagenext\">NEXT".$limit."</a>");
}else{
echo("NEXT".$limit);
}
mysql_free_result($result);
?>