php簡單的分頁程序第5/5頁
更新時間:2008年03月30日 01:05:20 作者:
php 分頁 簡單
=="")
$page=1;
//計算記錄偏移量
$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">序號</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">添加時間</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>" ;
}
//顯示總頁數(shù)
echo "<div align='center'>共有".$pages."頁(".$page."/".$pages.")<br>";
//顯示分頁數(shù)
for ($i=1;$i<$page;$i++)
echo "<a href='$SELF_PHP?page=".$i."'>第".$i ."頁</a> ";
echo "第".$page."頁 ";
for ($i=$page+1;$i<=$pages;$i++)
echo "<a href='$SELF_PHP?page=".$i."'>第".$i ."頁</a> ";
echo "<br>";
//顯示轉(zhuǎn)到頁數(shù)
echo "<form action='$SELF_PHP' method='post'> ";
//計算首頁、上一頁、下一頁、尾頁的頁數(shù)值
$first=1;
$prev=$page-1;
$next=$page+1;
$last=$pages;
if ($page>1)
{
echo "<a href='$SELF_PHP?page=".$first."'>首頁</a> ";
echo "<a href='$SELF_PHP?page=".$prev."'>上一頁</a> ";
}
if ($page<$pages)
{
echo "<a href='$SELF_PHP?page=".$next."'>下一頁</a> ";
echo "<a href='$SELF_PHP?page=".$last."'>尾頁</a> ";
}
echo "</form>";
echo "</div>";
?>
</table>
<p> </p>
</body>
</html>
[/code]
$page=1;
//計算記錄偏移量
$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">序號</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">添加時間</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>" ;
}
//顯示總頁數(shù)
echo "<div align='center'>共有".$pages."頁(".$page."/".$pages.")<br>";
//顯示分頁數(shù)
for ($i=1;$i<$page;$i++)
echo "<a href='$SELF_PHP?page=".$i."'>第".$i ."頁</a> ";
echo "第".$page."頁 ";
for ($i=$page+1;$i<=$pages;$i++)
echo "<a href='$SELF_PHP?page=".$i."'>第".$i ."頁</a> ";
echo "<br>";
//顯示轉(zhuǎn)到頁數(shù)
echo "<form action='$SELF_PHP' method='post'> ";
//計算首頁、上一頁、下一頁、尾頁的頁數(shù)值
$first=1;
$prev=$page-1;
$next=$page+1;
$last=$pages;
if ($page>1)
{
echo "<a href='$SELF_PHP?page=".$first."'>首頁</a> ";
echo "<a href='$SELF_PHP?page=".$prev."'>上一頁</a> ";
}
if ($page<$pages)
{
echo "<a href='$SELF_PHP?page=".$next."'>下一頁</a> ";
echo "<a href='$SELF_PHP?page=".$last."'>尾頁</a> ";
}
echo "</form>";
echo "</div>";
?>
</table>
<p> </p>
</body>
</html>
[/code]
您可能感興趣的文章:
- php,ajax實現(xiàn)分頁
- mysql+php分頁類(已測)
- PHP通用分頁類page.php[仿google分頁]
- php 分頁原理詳解
- php jquery 實現(xiàn)新聞標(biāo)簽分類與無刷新分頁
- PHP分頁函數(shù)代碼(簡單實用型)
- php下巧用select語句實現(xiàn)mysql分頁查詢
- 一個典型的PHP分頁實例代碼分享
- 精美漂亮的php分頁類代碼
- 使用PHP+JQuery+Ajax分頁的實現(xiàn)
- ThinkPHP分頁類使用詳解
- thinkphp實現(xiàn)數(shù)組分頁示例
- php實現(xiàn)的漂亮分頁方法
- ThinkPHP使用心得分享-分頁類Page的用法
- 高效mongodb的php分頁類(不使用skip)
- ThinkPHP讓分頁保持搜索狀態(tài)的方法
- ThinkPHP 3.2 數(shù)據(jù)分頁代碼分享
- ThinkPHP分頁實例
- php+ajax實現(xiàn)無刷新分頁的方法
- Thinkphp搜索時首頁分頁和搜索頁保持條件分頁的方法
- php實現(xiàn)分頁顯示
相關(guān)文章
phpStudy2016 配置多個域名期間遇到的問題小結(jié)
這篇文章主要介紹了phpStudy2016 配置多個域名期間遇到的問題小結(jié),需要的朋友可以參考下2017-10-10解決Linux下php-fpm進程過多導(dǎo)致內(nèi)存耗盡問題
這篇文章主要介紹了解決Linux下php-fpm進程過多導(dǎo)致內(nèi)存耗盡問題,需要的朋友可以參考下2017-12-12ThinkPHP的截取字符串函數(shù)無法顯示省略號的解決方法
這篇文章主要介紹了ThinkPHP的截取字符串函數(shù)無法顯示省略號的解決方法,需要的朋友可以參考下2014-06-06Thinkphp模板標(biāo)簽if和eq的區(qū)別和比較實例分析
這篇文章主要介紹了Thinkphp模板標(biāo)簽if和eq的區(qū)別和比較,實例分析了Thinkphp模板標(biāo)簽if和eq用于變量比較的區(qū)別,需要的朋友可以參考下2015-07-07PHP導(dǎo)出數(shù)據(jù)超時的優(yōu)化建議
當(dāng)數(shù)據(jù)訪問次數(shù)過多時,建議使用redis緩存一些固定數(shù)據(jù),減少mysql查詢次數(shù)。今天小編給大家分享PHP導(dǎo)出數(shù)據(jù)超時的優(yōu)化建議,感興趣的朋友一起看看吧2021-07-07