Jump to content

pagination


doddsey_65

Recommended Posts

i have some code which checks all of the posts in the database with the topic_id of $topic_id.

 

what i want to do is like on many forums. On the topic list next to the name just show the pages like:

 

1-2-3-4

 

and when there are more than 4 or so

 

1-2....8-9

 

here is the code which gets the number of pages:

 

$data = $db->query("SELECT * FROM
                    ".DB_PREFIX."posts
                    WHERE topic_id = '$topic_info->topic_id'");
$rows = mysql_num_rows($data); 
$page_rows = $posts_per_page; 

if ($rows > $page_rows) {

$rowsArray = array($rows);

}

 

as you can see i have added it into an array but i dont know what to do from there. I guessed it would be something like a for statement but im not sure. Can anyone help?

Link to comment
Share on other sites

Please make an attempt before asking us :D

 

It doesn't have to be code, it could be your though process... possible theoretical solutions.

 

For example: First, I have to figure out how many pages, so I grab the total amount of entries and divide it by entries per page. I then have to check if there are more than 4 pages, and what page the user is currently on... etc

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.