PHP’s simplest native sql statement paging
/**
* 1. Query the total number of data items
*/
$count = select count(*) from table name;
/**
* 2. Define the number of data items per page (5 items)
*/
$pagesize = 5;
/**
* 3. Get the total number of pages (rounded up)
*/
c eil(count/$pagesize);/**
* 4. Get the current page (pass value) */ pa g e = I
s
s
et (_get ['page']? $ _get ['page']: 1; // **
* 5. Get the offset */ start=
(
page-1)*$pagesize; /*
* 6. Query data on each page
*/ data = s
e
l
ec t?fr omtablenamelimi t(start ? : page?1;
next =
pag e+1>pagesum ? page sum: page+1;str="< ahre f=′jav
ascr ipt: page(1)′> first Page </a><ahre f= ′javascript: page (').addClass('pre-numbering').hide();
$(this).addClass('has-numbering').parent().append($numbering);
for (i = 1; i ').text(i));
};
$numbering.fadeIn(1700);
});
});
The above introduces the simplest native SQL statement paging in PHP, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.