AARRRRGHHH
This tutorial is driving me batty. Its actually darn close but I just need a little help. I'm sorry but I am going to post it so that I can explain it better.
$limit = 5;
$query_count = "SELECT COUNT(*) FROM reviews WHERE songid='$songid'";
$result_count = mysql_query($query_count, $conn);
//$totalrows = mysql_num_rows($result_count) or die(mysql_error());
$totalrows = mysql_result($result_count, 0) or die(mysql_error());
//exit($totalrows);
$limitvalue = $page * $limit - ($limit);
$query = "SELECT loginName, DATE_FORMAT(rdate, '%c/%e/%Y') AS rdate, rtitle, review FROM reviews WHERE songid = '$songid' ORDER BY rdate DESC LIMIT $limitvalue, $limit";
$result = mysql_query($query) or die("Error: " . mysql_error());
if(mysql_num_rows($result) == 0){
echo("No reviews available.");
}
while($row = mysql_fetch_array($result)){
$loginName = prepOut($row['loginName']);
$rdate = $row['rdate'];
$rtitle = prepOut($row['rtitle']);
$review = prepOut($row['review']);
echo "<tr>
TABLE INFORMATION WHICH PRINTS FINE
}
echo("</table>");
if($page != 1){
$pageprev = $page--;
echo("<a href=\"reviews.php?songid=$songid&stitle=$stitle&page=$pageprev\"><u>prev".$limit."</u></a> ");
}else{
echo("prev".$limit." ");
}
$numofpages = $totalrows / $limit;
for($i = 1; $i <= $numofpages; $i++){
if($i == $page){
echo($i." ");
}else{
echo("<a href=\"reviews.php?songid=$songid&stitle=$stitle&page=$i\"><u>$i</u></a> ");
}
}
if(($totalrows % $limit) != 0){
if($i == $page){
echo($i." ");
}else{
echo("<a href=\"reviews.php?songid=$songid&stitle=$stitle&page=$i\"><u>$i</u></a> ");
}
}
if(($totalrows - ($limit * $page)) > 0){
$pagenext = $page++;
echo("<a href=\"reviews.php?songid=$songid&stitle=$stitle&page=$pagenext\"><u>next".$limit."</u></a>");
}else{
echo("next".$limit);
}
mysql_free_result($result);
?>
Ok, first off, I noticed that nowhere in the script does it say to use a $get statement to retieve $page? I tried it with $page = $GET['page']; but it didnt help. This is the issue:
I have 12 reviews. I have limit set to display 5 results per page. On the first visit it displays this after the table echo:
prev5 1 2 3 next5
which is perfect, but for some reason the next5 link points to ...php?page=1 when it should be 2.
I apologize if this post is a clusterf***. 🙂
Thanks for any help.