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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.