php数据分页加数据显示效果
<?php
include_once (dirname(__FILE__) . '../../Inc/Conn.php');
include_once (dirname(__FILE__) . '../../photo/Inc/function.php');
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
body,td,th {
font-size: 12px;
height:17px;
padding:8px 0px 0px 0px;
text-align:center;
}
body {
margin-left: 0px;
margin-top: 10px;
margin-right: 0px;
margin-bottom: 0px;
}
td{
border:1px solid #333;
}
-->
</style></head>
<body>
<div style="height:26px;text-align:left; width:98%;font-size:16px; font-weight:bold; margin:0px auto;">
<a href="export.php" target="_blank">导出Execel表格</a></div>
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="8%"><strong>帐号</strong></td>
<td width="14%"><strong>邮箱</strong></td>
<td width="5%"><strong>性别</strong></td>
<td width="9%"><strong>宝宝出生日期</strong></td>
<td width="12%"><strong>省份</strong></td>
<td width="9%"><strong>真实姓名</strong></td>
<td width="12%"><strong>邮编</strong></td>
<td width="10%"><strong>手机</strong></td>
<td width="21%"><strong>地址</strong></td>
</tr>
<?php
$sql = "Select * from tablename";
$result = mysql_query($sql) or die('fail1' . mysql_error());
$rs = mysql_fetch_array($result);
$rdcount = mysql_num_rows($result);
if ($rdcount) {
$pagesize = 20;
$pagecount = ($rdcount % $pagesize) ? (int)($rdcount / $pagesize) + 1 : $rdcount / $pagesize; //统计总页面
$page = isset($_GET['page']) ? $_GET['page'] : 1; //取得当前页面
$start = ($page >= 1 && $page <= $pagecount) ? $start = $pagesize * ($page - 1) : $start = 1; //取得超始记录
$start = $start;
$sql = $sql . " order by add_date desc limit $start,$pagesize";
$result = mysql_query($sql) or die(mysql_error());
while ($rs = mysql_fetch_array($result)) {
echo "<tr>
<td>" . $rs['User_Name'] . "</td>
<td>" . $rs['User_Mail'] . "</td>
<td>" . $rs['User_Baby_Sex'] . "</td>
<td>" . $rs['User_Baby_Birth'] . " </td>
<td>" . $rs['sheng'] . " </td>
<td>" . $rs['User_rname'] . " </td>
<td>" . $rs['User_Zip'] . " </td>
<td>" . $rs['User_Hand'] . " </td>
<td>" . $rs['User_Address'] . " </td>
</tr>
";
}
echo "<tr> <td colspan=9>";
pagelist1($page, $pagecount, $rdcount, '?page=', $pagesize);
echo "</td> </tr> ";
} else {
echo '暂时没有信息!';
}
function pagelist1($page, $pagecount, $totalrecord, $url, $pagesize) {
if ($page == "" || $page > $pagecount) {
$page = 1;
}
echo ("记录" . $totalrecord . "条 每页" . $pagesize . "条 共" . $pagecount . "页 <a href=" . $url . "1> <<</a> ");
if ($page > 1) {
echo ("<a href=" . $url . ($page - 1) . "> < </a> ");
}
if ($page + 9 > $pagecount) {
$current = $pagecount;
} else {
$current = $page + 9;
}
for ($i = $page; $i <= $current; $i++) {
echo ("<a href=" . $url . "$i class='sf'>$i</a> ");
}
if ($pagecount > $page) {
echo ("<a href=" . $url . ($page + 1) . "> > </a> ");
}
echo ("<a href=" . $url . $pagecount . "> >></a> ");
}
?>
</table>
</body>
</html>本文地址:http://www.phprm.com/code/1d4de1c954622fa532d2ebb80b4aa512.html
转载随意,但请附上文章地址:-)