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
https://forums.phpfreaks.com/topic/214784-pagination/
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
https://forums.phpfreaks.com/topic/214784-pagination/#findComment-1117448
Share on other sites

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.