Home >Backend Development >PHP Tutorial >Simple and easy-to-understand modern magic animation. PHP introductory learning knowledge point 2. PHP simple paging process and principle

Simple and easy-to-understand modern magic animation. PHP introductory learning knowledge point 2. PHP simple paging process and principle

WBOY
WBOYOriginal
2016-07-29 08:46:021017browse

require '../inc/conn.php';
?>
//Initial parameter settings
$pagesize=5; //Page size
$pagenum=1; // The default is the first page
//Step 1: Get the current page
if($_GET){
if($_GET['pagenum']){
$pagenum=$_GET['pagenum'];
}
}
//Step 2: Get the content list of the current page
$sql="Select * From message limit ".($pagenum-1)*$pagesize.",$pagesize ";
$result=mysql_query( $sql);
while(($row=mysql_fetch_array($result))==true){
echo '


'.$row["title"].'';
}
//Step 3: Get the number of records
$sql="Select id From message";
$result=mysql_query($sql);
$rownum=mysql_num_rows($result);
//Step 4: Calculate the score Number of pages
if(($rownum%$pagesize)==0){
$pagecount=$rownum/$pagesize;
}else{
$pagecount=(int)($rownum/$pagesize);
}
/ /Step 5: Get the paging link
$url=$_SERVER["REQUEST_URI"];
$url=parse_url($url);
$url=$url["path"];
//Step 6: Output Pagination link
if($pagenum==1){
echo "[First page] [Previous page]";
}else{
echo "[ First page] [Previous page]";
}
if( $pagecount==$pagenum){
echo "[next page] [last page]";
}else{
echo "[Next page] [Last page]";
}
?>

The above introduces the simple and easy-to-understand modern magic animation PHP entry-level learning knowledge point 2. The simple paging process and principles of PHP, including the simple and easy-to-understand content of modern magic animation. I hope it will be helpful to friends who are interested in PHP tutorials.

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