PHP——MySQL数据库分页查询
生活随笔
收集整理的這篇文章主要介紹了
PHP——MySQL数据库分页查询
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
原理
?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><?phpinclude '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);" onclick="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') "><?phpif(empty( $row["維修時間"]) Or $row["維修時間"]="")echo "未完成" ;elseecho "已完成" . "</td><td>維修人:" . $row["維修人員"];?> </a> </td></tr></table><?phpecho "<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><?phpif ($pageNo>1)echo "<a href='note.php?pageNo=" . ($pageNo-1) . "'><input name='prepage' type='button' id='prepage' value='上一頁'></a>";?>頁碼: <?phpfor($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">頁<?phpif ($pageNo < $allpage)echo "<a href='note.php?pageNo=" . ($pageNo+1) . "'><input name='netpage' type='button' id='netpage' value='下一頁'></a>";?><?phpecho "<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
https://blog.csdn.net/wyh0930/article/details/83543035
https://blog.csdn.net/ccy1995414/article/details/80974545
總結
以上是生活随笔為你收集整理的PHP——MySQL数据库分页查询的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 阿里云安全组——添加安全组规则(开放端口
- 下一篇: PHP——MySQL数据库连接与关闭自定