Home >Backend Development >PHP Tutorial >php paging function_PHP tutorial

php paging function_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:08:07938browse

php paging function

php tutorial paging function

$conn=mysql tutorial_connect("localhost","root","123456");
$pagesize=4;//Set each page Number of records displayed on one page
mysql_select_db("ly",$conn);
$rs=mysql_query("select count(*) from lyb",$conn);//Get the total number of records $rs and calculate The total number of pages is calculated using
$myrow = mysql_fetch_array($rs);
$numrows=$myrow[0];
$pages=intval($numrows/$pagesize);//Calculate the total number of pages
if ($numrows%$pagesize)
$pages++;
//Set the number of pages
if (isset($_get['page'])){
$page=intval($ _get['page']);}
else{
//Set to the first page
$page=1;
}
//Calculate the record offset
$ offset=$pagesize*($page - 1);
//Read the specified number of records
$rs=mysql_query("select * from lyb order by id desc limit $offset,$pagesize",$conn) ;
if ($myrow = mysql_fetch_array($rs))
{
$i=0;
?>
 
 
 do {
$i++;
  ?>
  
 
 }
while ($myrow = mysql_fetch_array($rs));
echo "
< ?=$myrow["nichen"]?>
";
}


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/444904.htmlTechArticlephp paging function php tutorial paging function $conn=mysql tutorial_connect(localhost,root,123456); $pagesize =4;//Set the number of records displayed on each page mysql_select_db(ly,$conn); $rs=mysql_query(...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn