Home > Article > Backend Development > PHP simple paging program page 1/5_PHP tutorial
[code]
################## ########################################
##### ###### Connecting to the database ################
###################### ####################################
$db=mysql_connect("192.168.0.2 ","root","goalwe608"); //Database, username, password
mysql_select_db("86pos",$db); //Database
############ # Paging ############
//Set the number of records displayed on each page
$pagesize=5;
//Get the total number of records
$res= mysql_query("select count(id) from buyer " ,$db);
$myrow = mysql_fetch_array($res);
$numrows=$myrow[0];
//Calculate the total number of pages
$pages=intval($numrows/$pagesize);
if ($numrows%$pagesize)
$pages++;
//Determine whether the number of pages is set or not, if not, define it as the home page
if (!isset($page))
$page=1;
//Prevent malicious access
if ($_GET