开发者

php and mysql pagination help [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

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 question

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜