Jump to content

error with getting to last page


runnerjp

Recommended Posts

im trying to go to the last page of a topic so i have done this

 

in my links placed pagenum=last

 

and in my message area i have added..

 

if($pagenum === "last")
{
   $query = "Select COUNT(*) as C from forumtutorial_posts where parentid='$id'";
   $result = mysql_query($query);
   $data = mysql_fetch_array($result);
   $pagenum = floor($data['C'] / $page_rows) + 1;
}

 

it was working great untill have found a floor in it...  for some reason if the topic has 3 pages of posts and on each page it holds 5 posts..

 

when it gets to having 5 out of 5 posts with 2+ pages and the link is clicked for some reason it sends me to 4 out of 3 pages :S

 

any idea why??

Link to comment
https://forums.phpfreaks.com/topic/129984-error-with-getting-to-last-page/
Share on other sites

That piece of code is familiar... It's like I've written it :P

I don't really understand where you're having problems. Maybe you can post/PM me the link so I could see it?

 

Anyway, for debugging purposes, check the output given by:

 

<?php

if($pagenum === "last")
{
   $query = "Select COUNT(*) as C from forumtutorial_posts where parentid='$id'";
   $result = mysql_query($query);
   $data = mysql_fetch_array($result);
   $pagenum = floor($data['C'] / $page_rows) + 1;
   die ("Count is: ".$data['C']."<br>page_rows: ".$page_rows."<br>Pagenum: ".$pagenum);
}

?>

 

Orio.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.