Mysql
 sql >> Database >  >> RDS >> Mysql

Come visualizzare solo 5 record per pagina dalla tabella del mio database mysql tramite l'impaginazione?

Se vuoi solo codice PHP MySQL, di solito uso qualcosa di simile al seguente.

$page=max(intval($_GET['page']),1); // assuming there is a parameter 'page'
$itemsperpage = 5;
$total=100; // total results if you know it already otherwise use another query
$totalpages = max(ceil($total/$itemsperpage),1);
$query = "SELECT * FROM emp_master LIMIT ".(($page-1)*$itemsperpage).",".$itemsperpage; // this will return 5 items based on the page