php簡(jiǎn)單的分頁(yè)程序
更新時(shí)間:2008年03月30日 01:05:20 作者:
php 分頁(yè) 簡(jiǎn)單
=="")
$page=1;
//計(jì)算記錄偏移量
$offset=$pagesize*($page-1);
//取記錄
$res=mysql_query("select username,pass,mail,add_time from buyer order by add_time limit $offset,$pagesize" ,$db);
//循環(huán)顯示記錄
if ($myrow = mysql_fetch_array($res))
{
$i=0;
?>
</p>
<p> </p>
<table width="100%" border="0" align="center">
<tr>
<td width="40%" height="30"> </td>
<td width="20%" align="center"><span class="STYLE1">用戶信息管理<br>
<br>
</span></td>
<td width="15%"> </td>
<td><? $time=date ("Y-l-F H:i:s");echo $time;?>
</td>
</tr>
</table>
<div align="center">
-------------------------------------------------------------
</div>
<table width="90%" border="1" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="10%" height="24" bgcolor="#cccccc"><div align="center">序號(hào)</div></td>
<td width="20%" bgcolor="#cccccc"><div align="center">用戶名</div></td>
<td width="20%" bgcolor="#cccccc"><div align="center">密碼</div></td>
<td width="30%" bgcolor="#cccccc"><div align="center">電子郵箱</div></td>
<td bgcolor="#cccccc"><div align="center">添加時(shí)間</div></td>
</tr>
<?php
do
{
$i++;
?>
<tr>
<td width="10%"><div align="center"><?php echo $i;?></div></td>
<td><div align="center"><font size="2"> <?php echo $myrow['username'];?></font></div></td>
<td><div align="center"><font size="2"><?php echo $myrow['pass'];?></font></div></td>
<td><div align="center"><font size="2"><?php echo $myrow['mail'];?></font></div></td>
<td><div align="center"><font size="2"><?php echo $myrow['add_time'];?></font></div></td>
</tr>
<?php
}
while ($myrow = mysql_fetch_array($res));
echo "</table>" ;
}
//顯示總頁(yè)數(shù)
echo "<div align='center'>共有".$pages."頁(yè)(".$page."/".$pages.")<br>";
//顯示分頁(yè)數(shù)
for ($i=1;$i<$page;$i++)
echo "<a href='$SELF_PHP?page=".$i."'>第".$i ."頁(yè)</a> ";
echo "第".$page."頁(yè) ";
for ($i=$page+1;$i<=$pages;$i++)
echo "<a href='$SELF_PHP?page=".$i."'>第".$i ."頁(yè)</a> ";
echo "<br>";
//顯示轉(zhuǎn)到頁(yè)數(shù)
echo "<form action='$SELF_PHP' method='post'> ";
//計(jì)算首頁(yè)、上一頁(yè)、下一頁(yè)、尾頁(yè)的頁(yè)數(shù)值
$first=1;
$prev=$page-1;
$next=$page+1;
$last=$pages;
if ($page>1)
{
echo "<a href='$SELF_PHP?page=".$first."'>首頁(yè)</a> ";
echo "<a href='$SELF_PHP?page=".$prev."'>上一頁(yè)</a> ";
}
if ($page<$pages)
{
echo "<a href='$SELF_PHP?page=".$next."'>下一頁(yè)</a> ";
echo "<a href='$SELF_PHP?page=".$last."'>尾頁(yè)</a> ";
}
echo "</form>";
echo "</div>";
?>
</table>
<p> </p>
</body>
</html>
[/code]
$page=1;
//計(jì)算記錄偏移量
$offset=$pagesize*($page-1);
//取記錄
$res=mysql_query("select username,pass,mail,add_time from buyer order by add_time limit $offset,$pagesize" ,$db);
//循環(huán)顯示記錄
if ($myrow = mysql_fetch_array($res))
{
$i=0;
?>
</p>
<p> </p>
<table width="100%" border="0" align="center">
<tr>
<td width="40%" height="30"> </td>
<td width="20%" align="center"><span class="STYLE1">用戶信息管理<br>
<br>
</span></td>
<td width="15%"> </td>
<td><? $time=date ("Y-l-F H:i:s");echo $time;?>
</td>
</tr>
</table>
<div align="center">
-------------------------------------------------------------
</div>
<table width="90%" border="1" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="10%" height="24" bgcolor="#cccccc"><div align="center">序號(hào)</div></td>
<td width="20%" bgcolor="#cccccc"><div align="center">用戶名</div></td>
<td width="20%" bgcolor="#cccccc"><div align="center">密碼</div></td>
<td width="30%" bgcolor="#cccccc"><div align="center">電子郵箱</div></td>
<td bgcolor="#cccccc"><div align="center">添加時(shí)間</div></td>
</tr>
<?php
do
{
$i++;
?>
<tr>
<td width="10%"><div align="center"><?php echo $i;?></div></td>
<td><div align="center"><font size="2"> <?php echo $myrow['username'];?></font></div></td>
<td><div align="center"><font size="2"><?php echo $myrow['pass'];?></font></div></td>
<td><div align="center"><font size="2"><?php echo $myrow['mail'];?></font></div></td>
<td><div align="center"><font size="2"><?php echo $myrow['add_time'];?></font></div></td>
</tr>
<?php
}
while ($myrow = mysql_fetch_array($res));
echo "</table>" ;
}
//顯示總頁(yè)數(shù)
echo "<div align='center'>共有".$pages."頁(yè)(".$page."/".$pages.")<br>";
//顯示分頁(yè)數(shù)
for ($i=1;$i<$page;$i++)
echo "<a href='$SELF_PHP?page=".$i."'>第".$i ."頁(yè)</a> ";
echo "第".$page."頁(yè) ";
for ($i=$page+1;$i<=$pages;$i++)
echo "<a href='$SELF_PHP?page=".$i."'>第".$i ."頁(yè)</a> ";
echo "<br>";
//顯示轉(zhuǎn)到頁(yè)數(shù)
echo "<form action='$SELF_PHP' method='post'> ";
//計(jì)算首頁(yè)、上一頁(yè)、下一頁(yè)、尾頁(yè)的頁(yè)數(shù)值
$first=1;
$prev=$page-1;
$next=$page+1;
$last=$pages;
if ($page>1)
{
echo "<a href='$SELF_PHP?page=".$first."'>首頁(yè)</a> ";
echo "<a href='$SELF_PHP?page=".$prev."'>上一頁(yè)</a> ";
}
if ($page<$pages)
{
echo "<a href='$SELF_PHP?page=".$next."'>下一頁(yè)</a> ";
echo "<a href='$SELF_PHP?page=".$last."'>尾頁(yè)</a> ";
}
echo "</form>";
echo "</div>";
?>
</table>
<p> </p>
</body>
</html>
[/code]
您可能感興趣的文章:
- php,ajax實(shí)現(xiàn)分頁(yè)
- mysql+php分頁(yè)類(已測(cè))
- PHP通用分頁(yè)類page.php[仿google分頁(yè)]
- php 分頁(yè)原理詳解
- php jquery 實(shí)現(xiàn)新聞標(biāo)簽分類與無刷新分頁(yè)
- PHP分頁(yè)函數(shù)代碼(簡(jiǎn)單實(shí)用型)
- php下巧用select語句實(shí)現(xiàn)mysql分頁(yè)查詢
- 一個(gè)典型的PHP分頁(yè)實(shí)例代碼分享
- 精美漂亮的php分頁(yè)類代碼
- 使用PHP+JQuery+Ajax分頁(yè)的實(shí)現(xiàn)
- ThinkPHP分頁(yè)類使用詳解
- thinkphp實(shí)現(xiàn)數(shù)組分頁(yè)示例
- php實(shí)現(xiàn)的漂亮分頁(yè)方法
- ThinkPHP使用心得分享-分頁(yè)類Page的用法
- 高效mongodb的php分頁(yè)類(不使用skip)
- ThinkPHP讓分頁(yè)保持搜索狀態(tài)的方法
- ThinkPHP 3.2 數(shù)據(jù)分頁(yè)代碼分享
- ThinkPHP分頁(yè)實(shí)例
- php+ajax實(shí)現(xiàn)無刷新分頁(yè)的方法
- Thinkphp搜索時(shí)首頁(yè)分頁(yè)和搜索頁(yè)保持條件分頁(yè)的方法
- php實(shí)現(xiàn)分頁(yè)顯示
相關(guān)文章
phpStudy2016 配置多個(gè)域名期間遇到的問題小結(jié)
這篇文章主要介紹了phpStudy2016 配置多個(gè)域名期間遇到的問題小結(jié),需要的朋友可以參考下2017-10-10解決Linux下php-fpm進(jìn)程過多導(dǎo)致內(nèi)存耗盡問題
這篇文章主要介紹了解決Linux下php-fpm進(jìn)程過多導(dǎo)致內(nèi)存耗盡問題,需要的朋友可以參考下2017-12-12ThinkPHP的截取字符串函數(shù)無法顯示省略號(hào)的解決方法
這篇文章主要介紹了ThinkPHP的截取字符串函數(shù)無法顯示省略號(hào)的解決方法,需要的朋友可以參考下2014-06-06Thinkphp模板標(biāo)簽if和eq的區(qū)別和比較實(shí)例分析
這篇文章主要介紹了Thinkphp模板標(biāo)簽if和eq的區(qū)別和比較,實(shí)例分析了Thinkphp模板標(biāo)簽if和eq用于變量比較的區(qū)別,需要的朋友可以參考下2015-07-07ThinkPHP驗(yàn)證碼和分頁(yè)實(shí)例教程
這篇文章主要介紹了ThinkPHP驗(yàn)證碼和分頁(yè)實(shí)例教程,是ThinkPHP中常見的應(yīng)用,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2014-08-08PHP導(dǎo)出數(shù)據(jù)超時(shí)的優(yōu)化建議
當(dāng)數(shù)據(jù)訪問次數(shù)過多時(shí),建議使用redis緩存一些固定數(shù)據(jù),減少mysql查詢次數(shù)。今天小編給大家分享PHP導(dǎo)出數(shù)據(jù)超時(shí)的優(yōu)化建議,感興趣的朋友一起看看吧2021-07-07