php and mysql pagination help [closed]
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with 开发者_如何学运维facts and citations.
Closed 8 years ago.
Improve this questionI need to make a pagination like this that displays the number of data from a table in my database like this:
1 of n pages
Can anyone recommend a good tutorial for this? Thanks.
It's not a link, it just has to indicate the number of rows inside the database.
You can calculate the total number of rows during a select by adding the SQL_CALC_FOUND_ROWS flag to your query, and following it up with a second SELECT statement:
SELECT SQL_CALC_FOUND_ROWS * FROM tablename WHERE criteria='here' LIMIT 0,25;
SELECT FOUND_ROWS();
By knowing that you've got 25 rows on the first page (in the LIMIT), and knowing how many total rows there are, you can calculate how many pages there should be.
精彩评论