<?php
include("conn.php")
$page_size=2
$url=$_SERVER["REQUEST_URL"]
$url=parse_url($url)
$url=$url[path]
$numq=mysql_query("SELECT * FROM `page`")
$num=mysql_num_rows($numq)//echo $num14
$page_first=1
$page_last=ceil($num/$page_size)
if ($_GET[page]>=1){
$page_num=$_GET[page]
$page_nums=($page_num-1)*$page_size
}else{
$page_num=1
$page_nums=($page_num-1)*$page_size
}
/***********************************head**************************************************/
echo "共".$num."条记录,共".$page_last."页"."<br>"
if($page_num>1){
echo "<a href=$url?page=".$page_first.">首页</a>" .
"<a href=$url?page=".($page_num-1).">上一页</a>"
}
/*************************************************************************************/
if($page_last<=5){
for($i=1$i<=$page_last$i++){
echo "<a href=$url?page=".$i.">"."第".$i."页| "."</a>"
}
}else if(($page_num+5-1)<=$page_last){
for($i=1$i<=5$i++){
echo "<a href=$url2?page=".($page_num+$i-1).">"."第".($page_num+$i-1)."页>>"."</a>"
}
}else{
for($i=$page_num$i<=$page_last$i++){
echo "<a href=$url2?page=".$i.">"."第".$i."页>>"."</a>"
}
}
/*************************************************************************************/
if($page_num<$page_last){
echo "<a href=$url?page=".($page_num+1).">下一页</a>".
"<a href=$url?page=".$page_last.">尾页</a>"
}
/*************************************************************************************/
$sql="SELECT * FROM `page` limit $page_nums,$page_size"
$query=mysql_query($sql)
echo "<table border=1><tr bgcolor=\"#336633\"><th>姓名</th><th>姓别</th></tr>"
while($row=mysql_fetch_array($query)){//echo $rowArray /echo $row[1]张1张2张3
echo "<tr ><td>"
echo $row[name]
echo "</td>"
echo "<td>"
echo $row[sex]
echo "</td></tr>"
}
echo "</table>"
echo "<br>"
echo "共".$num."条记录!".
"<a href=$url?page=".$page_first.">首页</a>" .
"<a href=$url?page=".($page_num-1).">上一页</a>" .
"<a href=$url?page=".($page_num+1).">下一页</a>".
"<a href=$url?page=".$page_last.">尾页</a>"
echo"<script language=\"javascript\">
function go(){
window.location.href=se.value
}
</script>"
echo "<select onchange=\"go()\" name=\"se\">"
for ($k=1$k<=$page_last$k++){
echo "<option value=".$url."?page="."$k>".$k."</option>"
}
echo "</select>"
?>
欢迎分享,转载请注明来源:优选云