php5 mysql paging example code_PHP tutorial

WBOY
Release: 2016-07-21 15:52:46
Original
750 people have browsed it

Copy code The code is as follows:

//Connect to the database
$db=mysql_connect("localhost","root","");
mysql_select_db("hy",$db);
//Set the number of records displayed on each page
$pagesize=25;
//Get the total number of records and calculate the total number of pages
$res=mysql_query("select count(*) from main numrows/$pagesize);                                                                                                        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 > $res=mysql_query("select id,title from main order by id desc limit $offset,$pagesize" ,$db);
//Loop display of records
if ($myrow = mysql_f etch_array($res) )
{ $i=0;
?> >

Content

do $i++;                                                                   td> id=')" >

}
while ($myrow = mysql_fetch_array($res));
echo "" ;                                                                
//Display the total number of pages
echo "
There are ".$pages." pages (".$page."/".$pages.")Page ".$i ." " ";
echo ".$page."Page "; $i<=$pages;$i++)
echo "Page ".$i ." " ;

echo "
";
//Show the page number
echo "
";
//Calculate the page values ​​of the homepage, previous page, next page and last page                                                                                                      
$last=$pages;
if ($page>1)
{
echo "Home page                                                                    if ($page<$pages)
{
echo "Next page ";
echo "Last page " ";
}
echo "Go topage";
echo "";
echo "
";
echo "
";

?>






http://www.bkjia.com/PHPjc/318881.html

www.bkjia.com

true
http: //www.bkjia.com/PHPjc/318881.html

TechArticle

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!