<?php
include("conn.php");
$pagesize=5;
$url=$_SERVER["REQUEST_URL"];
$url=parse_url($url);
$url=$url[path];
$numq=mysql_query("SELECT * FROM test ");
$num=mysql_num_rows($numq);
if($_GET){
$pageval=$_GET;
//从第几页开始
$page=($pageval-1)*$pagesize;
$page.=",";
}
if($num > $pagesize){
if($pageval<=1)$pageval=1;
echo "共".$num."条"."<a href=$url?page=".($pageval-1).">上一页</a><a href=$url?page=".($pageval+1).">下一页</a>";
}
echo $SQL = "SELECT * FROM test limit $page,$pagesize";
$query=mysql_query($SQL);
while($row = mysql_fetch_array($query)){
echo "<hr><br>".$row[name]."|".$row[sex];
}
?>