nice mysqli pagination class. Once it’s implemented, it is used like this:
/**
* $db is your mysqli connection
* $query is your query
* 'mailPage' is the $_GET variable to use for the pages. It defaults to 'page' but using different values lets you have separate
* paginated data on that same web page. Setting multiple paginated items on the same webpage to the same "page" variable
* will mean that when one goes to page two, all of them go to page 2.
*/
$query = <<<
SELECT
`mail`.`id`,
`mail2`.`read`,
`mail2`.`seen`,
`mail`.`from`,
`mail`.`sent`,
`mail`.`subject`,
`mail`.`body`,
`users`.`full_name` as from_name
FROM `mail`
JOIN `users`
ON (`mail`.`from` = `users`.`id`)
JOIN `mail2`
ON (`mail`.`id` = `mail2`.`mess_id`)
WHERE
`mail2`.`uid`=1 &&
`mail2`.`folder`=1
ORDER BY
`mail`.`sent` DESC
EOQ;
// Create our paginate object, and pass it the database, query, and page var
$paginate = new Paginate($db, $query, 'mailPage');
// Run the query
$r = $paginate->get_results();
// Loop through our results
while ($message = $r->fetch_object()) {
// Create your page of information
}
// Show the page links
echo $paginate->show_pages();
