标签:
include("conn.php");
//取URL值
$pagesize=10;
$url=$_SERVER["REQUEST_URI"];
$url=parse_url($url);
$url=$url[path];
$total_row=mysql_num_rows(mysql_query("select * from data_test")); //取总条数 if($_GET[page]){
$pagevalue=$_GET[page];
$page=($pagevalue-1)*$pagesize;
$page.=,;
}
$pagenum=ceil($total_row/$pagesize); //取page页数 echo "<table width=792 height=56 border=0 cellspacing=1> ";
echo "<tr bgcolor=#9999FF>";
echo "<th width=33 scope=col>id</th>";
echo "<th width=91 scope=col>trans_type</th> ";
echo "<th width=86 scope=col>trans_amt</th> ";
echo "<th width=113 scope=col>trans_date</th>";
echo "<th width=68 scope=col>sinage</th>";
echo "<th width=246 scope=col>insert_date</th>";
echo "<th width=109 scope=col>note</th>";
echo "</tr>"; $all_sql = "select * from data_test limit $page $pagesize"; $query = mysql_query($all_sql);
while ($row = mysql_fetch_array($query)){
echo "<tr bgcolor=#99FF00>";
echo "<td>$row[0]</td>";
echo "<td>$row[1]</td>";
echo "<td>$row[2]</td>";
echo "<td>$row[3]</td>";
echo "<td>$row[4]</td>";
echo "<td>$row[5]</td>";
echo "<td>$row[6]</td>";
echo "</tr>";
}echo "</table>";
if($total_row>=$pagesize){ //判断总记录数是否大于每页条数
echo "<a href=$url?page=".($pagevalue=1).">首页</a>";
}
for($i=1;$i<=$pagenum;$i++){ //循环page页数
$show = "<a href=$url?page=".($i).">$i</a>";
echo $show."";
} if($i>=$pagenum){ //判断page页数是否显示结束
echo "<a href=$url?page=".($i-1).">尾页</a>";
}
echo 共.$total_row.条 每页共.$pagesize.条 当前第.$page.条;?>
标签:
原文地址:http://www.cnblogs.com/wang1204/p/5644831.html