PHP——MySQL数据库分页查询
程序员文章站
2022-04-12 13:14:42
...
原理
https://blog.csdn.net/weixin_43272781/article/details/101319460
效果
代码
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML xmlns="http://www.w3.org/1999/xhtml">
<head>
<TITLE>查询</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<META content="text/html; charset=UTF-8" http-equiv=Content-Type>
<LINK rel=stylesheet type=text/css href="./assets/css/index.css">
</head>
<BODY>
<DIV id=page>
<DIV id=header>
<DIV id=headerimg>
<H1>维修预约</H1>
<DIV class=description>计算机协会——维修部</DIV>
</DIV>
</DIV>
<?php
include 'conn.php';
?>
<HR>
<DIV id=content class=widecolumn>
<H2>全部预约</H2>
<?php
$rstot=mysqli_query($connID,"select * from wxyy order by 时间 DESC");
$rows=mysqli_num_rows($rstot);
mysqli_free_result($rstot);
$pageSize=5;
$allpage=(int)((float)($rows)/$pageSize);
if ($allpage*$pageSize <$rows){
$allpage=$allpage+1;
}
if (isset($_GET["pageNo"])){
$pageNo=$_GET["pageNo"];
}else{
$pageNo=1;
}
if (is_numeric($pageNo))
$pageNo=(int)$pageNo;
else
$pageNo=1;
if( $pageNo < 0)
$pageNo=1;
if ($pageNo > $allpage)
$pageNo=$allpage;
$rs=mysqli_query($connID,"select * from wxyy order by 时间 DESC limit ".($pageNo-1)*$pageSize.",".$pageSize);
//echo "select * from wxyy order by 时间 DESC limit ".($pageNo-1)*$pageSize.",".$pageSize;
if(mysqli_num_rows($rs)==0){
?>
<DIV class="postmetadata alt">
没有任何预约
<hr style='display:block'>
</DIV>
<?php
}else{
echo "<br>";
echo "<br>" ;
echo "<hr style='display:block'>";
while($row=mysqli_fetch_assoc($rs)){
//echo "<p>";
//echo var_dump($row);
?>
<table width="100%" border="0">
<tr><td width="15%">预约编号: </td><td width="15%"><?php echo $row["ID"]?> </td><td>预约时间:<?php echo date("Y-m-d H:i:s",strtotime($row["时间"]));?> </td></tr>
<tr><td>基本信息: </td>
<td colspan="3"><?php echo $row["姓名"]."|".$row["电话"]."|".$row["QQ"]."|" . $row["地址"] ?> </td>
</tr>
<tr><td>问题描述: </td>
<td colspan="3"><?php echo $row["故障描述"]?> </td>
</tr>
<tr>
<td>完成情况: </td>
<td>
<a href="javascript:void(0);" οnclick="window.open ('done.asp?ID=<?php echo $row["ID"]?>', 'newwindow', 'height=600, width=800, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no') ">
<?php
if(empty( $row["维修时间"]) Or $row["维修时间"]="")
echo "未完成" ;
else
echo "已完成" . "</td><td>维修人:" . $row["维修人员"];
?>
</a>
</td>
</tr>
</table>
<?php
echo "<hr style='display:block'>";
}
mysqli_free_result($rs);
mysqli_close($connID);
}
?>
<center>
<a href="note.php?pageNo=1"><input name="firstpage" type="button" id="firstpage" value="首页"></a>
<?php
if ($pageNo>1)
echo "<a href='note.php?pageNo=" . ($pageNo-1) . "'><input name='prepage' type='button' id='prepage' value='上一页'></a>";
?>
页码:
<?php
for($i=$pageNo-2;$i<=$pageNo+2;$i++)
if ($i>0 and $i <= $allpage)
echo "<a href=note.php?pageNo=" . $i . ">" . $i . "</a> ";
?>
<input name="pageno" type="text" id="pageno" size="1">页
<?php
if ($pageNo < $allpage)
echo "<a href='note.php?pageNo=" . ($pageNo+1) . "'><input name='netpage' type='button' id='netpage' value='下一页'></a>";
?>
<?php
echo "<a href='note.php?pageNo=" . $allpage . "'><input name='endpage' type='button' id='endpage' value='末页'></a>";
?>
</center>
</DIV>
<HR>
<DIV id=footer>
<P>Copyright© 2019 ZSTUCA<BR><a href="http://www.beian.miit.gov.cn/">浙ICP备19031217号-1</a> </P>
</DIV>
</DIV>
</BODY>
</HTML>
参考文章
https://blog.csdn.net/weixin_43272781/article/details/101319460
上一篇: 生成多个不重复的随机数字php
下一篇: 递归和循环
推荐阅读
-
优化MySQL数据库查询的三种方法_MySQL
-
php使用mysql_query查询超大结果集超内存的解决方法,phpmysql_query_PHP教程
-
基于MySQL数据库的UTF8中文网站全文检索的实现_PHP
-
php+mysql 分页有关问题
-
php将mysql数据库整库导出生成sql文件的具体实现_PHP
-
php 数据库mysql查询与连接类_PHP教程
-
thinkphp3.x连接mysql数据库的方法(具体操作步骤)_php实例
-
php 导入csv数据到mysql数据库_PHP教程
-
mysql - 怎样记录thinkphp函数生成的数据库查询语句呢?
-
Php连接及读取和写入mysql数据库的常用代码