Read n data from the database and want to page out the N data
1, how do I page out this data so that it shows 10 data per page
2. How to calculate the total number of pages
I hope I can give you an example.
Reply to discussion (solution)
SELECT * FROM table WHERE xxxxxx LIMIT $start _page,10;
$start _page is the number of start bars per page of your
1. First Use SELECT COUNT (*) from table where xxx gets the total number of records
2. (total-1)/10+1 = total number of pages. If total=0, the total number of pages is 0
SELECT * FROM tablename limit 5,10
Pagination can be written like this
$page = 1; To reality the first few pages of data $pagesize = 10; Show 10 data per page $offset = ($page-1) * $pagesize; Calculates the offset number based on the number of pages and records per page $SQLSTR = "SELECT * FROM Table Limit". $offset. ",". $pagesize;
Pagination can be written like this
$page = 1; To reality the first few pages of data $pagesize = 10; Show 10 data per page $offset = ($page-1) * $pagesize; Calculates the offset number based on the number of pages and records per page $SQLSTR = "SELECT * FROM Table Limit". $offset. ",". $pagesize;
$page, $pagesize, $offset These variables to be stored in the session?
No!
$page is incoming.
$pagesize is specified in the program.
$offset is calculated.
Determine the total number of pages according to the total bar, and then how much to check.