This site does an awesome job when it comes to its recordset paging (pagination) and wanted do do away with my current one at
http://scasp.com/testing/reviews.php
And use this sites style in its place, my current one is useless anyway as it throws an error?
Heres the code
$limit = 50;
$query_count = "SELECT count(*) FROM REVIEW";
$result_count = mysql_query($query_count);
$totalrows = mysql_num_rows($result_count);
if(empty($page)){
$page = 1;
}
$limitvalue = $page * $limit - ($limit);
$query = "SELECT ID, DATE_FORMAT(R_Date, '%c/%e/%Y') as date, ASP_Name, Username FROM REVIEW ORDER BY R_Date DESC LIMIT $limitvalue, $limit";
$total = mysql_num_rows($query);
$real_result = mysql_query($query) or die("Error: " . mysql_error()); //Do the query
if(mysql_num_rows($real_result))// There are rows in the result
{
$i = 0;
while ($result = mysql_fetch_array($real_result )) {
if($i++ % 2) {
$bgcolor = "#ffffff";
$id = "category";
} else {
$bgcolor = "#DFE6EF";
$id = "";
}
print "<tr bgcolor=\"$bgcolor\" id=\"$id\">";
print "<TD><a href=show_reviev.php?ID=".$result['ID'].">".$result['ASP_Name']."</a></TD>";
print "<TD>".$result['Username']."</TD>";
print "<TD>".$result['date']."</TD>";
print "</TR>\n";
}
}
if(mysql_num_rows($real_result) == 0){
echo("<tr><td colspan=3 align=center>~Nothing to Display~</td></tr>");
}
if($page != 1){
$pageprev = $page--;
echo("<a href=\"$PHP_SELF&page=$pageprev\"><</a> ");
}else{
echo("< ");
}
$numofpages = $totalrows / $limit;
for($i = 1; $i <= $numofpages; $i++){
if($i == $page){
echo($i." ");
}else{
echo("<a href=\"$PHP_SELF?page=$i\">$i</a> ");
}
}
if(($totalrows % $limit) != 0){
if($i == $page){
echo($i." ");
}else{
echo("<a href=\"$PHP_SELF?page=$i\">$i</a> ");
}
}
if(($totalrows - ($limit * $page)) > 0){
$pagenext = $page++;
echo("<a href=\"$PHP_SELF?page=$pagenext\">></a>");
}else{
echo(">");
}
$all_pages = ($total/$limit);
echo "Page $page Of $all_pages";
mysql_free_result($real_result);
Thanks