无为清净楼资源网 Design By www.qnjia.com
本文实例讲述了PHP+MySQL实现输入页码跳转到指定页面功能。分享给大家供大家参考,具体如下:
一、代码
conn.php:
<"localhost","root","root")or dir('连接失败' . mysql_error()); if(mysql_select_db("db_database13",$id)) echo ""; else echo ('连接失败' . mysql_error()); mysql_query("set names gb2312"); "htmlcode"><"conn/conn.php"); if ($_GET['page']=="") {$_GET['page']=1;};"Content-Type" content="text/html; charset=gb2312" /> <title>查询结果的分页显示</title> <style type="text/css"> <!-- .STYLE1 {font-size: 12px} .STYLE2 {font-size: 13px} a:link { text-decoration: none; } a:visited { text-decoration: none; } a:hover { text-decoration: none; } a:active { text-decoration: none; } --> </style> </head> <script language="javascript"> function chk(form){ if(form.page.value<=0||form.page.value>form.pages.value){ alert("您输入的页码无效!!"); form.page.focus(); return(false); } return(true); } </script> <body> <table width="500" border="0" cellpadding="0" cellspacing="1" bgcolor="#11DFF0"> <tr> <td width="100" height="25" align="center" bgcolor="#11DFF0" class="STYLE2">姓名</td> <td width="100" align="center" bgcolor="#11DFF0" class="STYLE2">编号</td> <td width="125" align="center" bgcolor="#11DFF0" class="STYLE2">电话</td> <td width="175" align="center" bgcolor="#11DFF0" class="STYLE2">地址</td> </tr> <"select count(*) as total from tb_insert"; $result=mysql_query($query); $message_count=mysql_result($result,0,"total"); $page_count=ceil($message_count/$page_size); $offset=($_GET['page']-1)*$page_size; $query="select * from tb_insert where id order by id desc limit $offset, $page_size"; $result=mysql_query($query); while ($myrow=@mysql_fetch_array($result)){ "25" align="center" bgcolor="#FFFFFF"><span class="STYLE2"><"center" bgcolor="#FFFFFF"><span class="STYLE2"><"center" bgcolor="#FFFFFF"><span class="STYLE2"><"center" bgcolor="#FFFFFF"><span class="STYLE2"><"form1" method="get" action="index.php" onSubmit="return chk(this)"> <table width="500" border="1" cellpadding="0" cellspacing="0" bgcolor="#11DFF0"> <tr> <td width="42%" align="center" valign="middle"><span class="STYLE1"> 页次:<"58%" height="28" align="left" valign="middle"><span class="STYLE1"> 分页: <"<a href=index.php"; echo "<a href=index.php".($_GET['page']-1).">上一页</a> "; } if($_GET['page']<$page_count) { echo "<a href=index.php".($_GET['page']+1).">下一页</a> "; echo "<a href=index.php".$page_count.">尾页</a>"; if($_GET['page']<= $page_count and $_GET['page']>0) { echo "<a href=index.php".$_GET['page']."></a>"; } } "page" type="text" size="3"> <input type="hidden" name="pages" value="<"> <input type="submit" name="Submit" value="跳转"> </span> </td> </tr> </table> </form> </body> </html>二、运行结果
更多关于PHP相关内容感兴趣的读者可查看本站专题:《php+mysql数据库操作入门教程》、《php+mysqli数据库程序设计技巧总结》、《php面向对象程序设计入门教程》、《PHP数组(Array)操作技巧大全》、《php字符串(string)用法总结》及《php常见数据库操作技巧汇总》
希望本文所述对大家PHP程序设计有所帮助。
无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com
暂无评论...
更新日志
2024年09月25日
2024年09月25日
- 纯音入心系列纯音乐《天籁古筝》1CD[MP3][331MB]
- 男女对唱典藏天碟《发烧对唱·那个季节里的歌DSD》10CD[WAV]
- 群星2010-歌林精选辑[歌林][WAV+CUE]
- TrioZimbalist-PianoTriosofWeinberg,Auerbach,Dvorak(2024)[24-44,1]wav
- 群星.1992-滚石第一流台湾歌·12王牌大车拼【滚石】【WAV+CUE】
- 林子祥.1984-创作歌集【华纳】【WAV+CUE】
- 周汤豪.2010-周汤豪【华纳】【FLAC分轨】
- Mozart-TheStringQuintets-AmadeusQuartet,CecilAronowitz(2017)[24-44,1][WAV+CUE]
- JamesWilliamsDennisIrwin-Focus(2024,Red)[24-48]FLAC
- 藤泽麻衣《空みあげて》[WAV]
- 纯音入心系列纯音乐《中国古筝经典名曲》1CD[MP3][1.3GB]
- 纯音入心系列纯音乐《古筝新奏:岁月静好与筝语,细水流年与筝同》1CD[MP3][846.9MB]
- 670《脆弱敏感小女生》[320K/MP3][27.53MB]
- 曾琳.2011-好好爱我【南方】【WAV+CUE】
- 范晓萱.1995-RAIN【福茂】【WAV+CUE】