Home > Backend Development > PHP Tutorial > Implement page turning function_PHP tutorial

Implement page turning function_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:58:53
Original
967 people have browsed it

$limit=25;
if (!empty($start)) $start=0;
if (!empty($s)) $s=0;

mysql_connect("localhost","","");
mysql_select_db(database);

//统计数据库记录总数
$result=mysql_query("select * from table");
$num=mysql_numrows($result);

$result=mysql_query("select * from table order by id limit $start,$limit");
$numb=mysql_numrows($result);
echo "

";
if (!empty($numb)) {
for($i=0;$i<$numb;$i++) {
$val=mysql_result($result,$i,"val");
$val1=mysql_result($result,$i,"val1");
echo "";
}
}
echo "
$val$val1
";

//数字循环翻页的控制
echo "

";
echo "";

//前翻控制
if ($s>20) {
if ($s==21) {
$st=$s-21;
} else {
$st=$s-20;
}
$pstart=$st*$limit;
echo "

";
}
echo "";

//设置当前页对应页数无链接功能
$star=$start;

//注意循环的初始附值,仔细想想为什么不是 0
for ($page=$s;$page<($num/$limit);$page++) {

$start=$page*$limit;
echo "

";

//控制数字页面限制显示功能,控制只显示 20 页
if ($page>0 && ($page%20)==0) {
if ($s==0) {
$s=$s+21;
} else {
$s=$s+20;
}

$start=$start+$limit;

if ((($num/$limit)-1)>$page) {
echo "

";
}
//注意跳出循环的控制
break;
}
}
echo "
页: echo "start=$pstart&s=$st>prve >> ";

if($page!=$star/$limit) {
echo " echo "start=$start&s=$s>";
}

echo $page;

if($page!=$star/$limit) {
echo "
";
}

echo "

<< echo "start=$start&s=$s>next
";
?>

以上的程已序可以完成强大的循环翻页功能

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/631946.htmlTechArticle? $limit=25; if (!empty($start)) $start=0; if (!empty($s)) $s=0; mysql_connect(localhost,,); mysql_select_db(database); //统计数据库记录总数 $result=mysql_query(select * f...
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
Latest Issues
ubuntu mongodb 出现 exception: connect failed
From 1970-01-01 08:00:00
0
0
0
An error occurred
From 1970-01-01 08:00:00
0
0
0
Why does clicking login jump to hello world?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template