Copy the code The code is as follows:
//Connect to the database
$db=mysql_connect("localhost","root","");
mysql_select_db("hy",$db);
//Set the content displayed on each page Number of records
$pagesize=25;
//Get the total number of records and calculate the total number of pages using
$res=mysql_query("select count(*) from main " " ,$db);
$myrow = mysql_ fetch_array($res);
$numrows=$myrow[0];
//Calculate the total number of pages
$pages=intval($numrows/$pagesize);
if ($numrows%$pagesize)
$pages++;
//Determine the page number setting or not, if not, it is defined as the homepage
if (!isset($page))
$page=1;
//Judge the number of pages to go to
if (isset($ys))
if ($ys>$pages )
$page=$pages;
else
$page=$ys;
//Calculate the record offset
$offset=$pagesize*($page-1);
//Get the record
$res=my sql_query( "select id,title from main order by id desc limit $offset,$pagesize" ,$db);
//Loop display of records
if ($myrow = mysql_fetch_array($res))
{
$i=0;
?> FB ">