<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<?php
$con = mysql_connect("localhost","root","root");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
if($_GET['page']==null)
$currentpage=1;
else
$currentpage=$_GET['page'];
mysql_select_db("people", $con);
$sql = "SELECT count(*) from person";
$count = mysql_query($sql);
$result = mysql_query("SELECT * FROM person limit ".(($currentpage-1)*3).",3");
echo "<center><table border=1 cellspacing=0>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>".$row['name'] . "</td><td>" . $row['age']."</td><td>".$row['sex']."</td>";
echo "</tr>";
}
if($currentpage!=1&& $currentpage!=(int)($count/3+1))
{
echo "<td colspan=3><a href='?page=".($currentpage-1)."'".">上一页</a>";
echo "<a href='?page=".($currentpage+1)."'".">下一页</a>";
echo "<a href='index.php'>首页</td></tr >";
}
if($currentpage==1)
{
echo "<td colspan=3>上一页";
echo "<a href='?page=".($currentpage+1)."'".">下一页</a>";
echo "<a href='index.php'>首页</a></td></tr >";
}
if($currentpage==(int)($count/3+1))
{
echo "<td colspan=3><a href='?page=".($currentpage-1)."'".">上一页</a>";
echo "下一页";
echo "<a href='index.php'>首页</a></td></tr >";
}
echo "<table></center>";
echo (int)$count;
mysql_close($con);
?>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<?php
$con = mysql_connect("localhost","root","root");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
if($_GET['page']==null)
$currentpage=1;
else
$currentpage=$_GET['page'];
mysql_select_db("people", $con);
$sql = "SELECT count(*) from person";
$count = mysql_query($sql);
$result = mysql_query("SELECT * FROM person limit ".(($currentpage-1)*3).",3");
echo "<center><table border=1 cellspacing=0>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>".$row['name'] . "</td><td>" . $row['age']."</td><td>".$row['sex']."</td>";
echo "</tr>";
}
if($currentpage!=1&& $currentpage!=(int)($count/3+1))
{
echo "<td colspan=3><a href='?page=".($currentpage-1)."'".">上一页</a>";
echo "<a href='?page=".($currentpage+1)."'".">下一页</a>";
echo "<a href='index.php'>首页</td></tr >";
}
if($currentpage==1)
{
echo "<td colspan=3>上一页";
echo "<a href='?page=".($currentpage+1)."'".">下一页</a>";
echo "<a href='index.php'>首页</a></td></tr >";
}
if($currentpage==(int)($count/3+1))
{
echo "<td colspan=3><a href='?page=".($currentpage-1)."'".">上一页</a>";
echo "下一页";
echo "<a href='index.php'>首页</a></td></tr >";
}
echo "<table></center>";
echo (int)$count;
mysql_close($con);
?>
</body>
</html>