<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>雇员信息列表</title>
</head>
<?php
$conn=mysql_connect("localhost","root","1234") or die(mysql_error());
mysql_query("set names utf8");
mysql_select_db("empmanage",$conn);
$pageSize=3; //每页显示多少条
$rowCount=0; //一共有多少条数据
$pageNow=1; //当前第几页
if(!empty($_GET['pageNow'])){
$pageNow=$_GET['pageNow'];//得到的当前页数
}
$sql="select count(id) from emp"; //获取数据库一个共有多少条数据
$resf=mysql_query($sql);
if($row=mysql_fetch_array($resf)){
$rowCount=$row['0'];
}
$pageCount=ceil($rowCount/$pageSize);//一个多少页
$sql="select * from emp limit ".($pageNow-1)*$pageSize.",".$pageSize."";
$res=mysql_query($sql);
echo "<table width='700px' border='1px'>";
echo "<tr><th>id</th><th>name</th><th>grade</th><th>email</th><th>salary</th><th>删除</th><th>修改</th></tr>";
while($row=mysql_fetch_assoc($res)){
echo "<tr><td>{$row['id']}</td><td>{$row['name']}</td><td>{$row['grade']}</td><td>{$row['email']}</td><td>{$row['salary']}</td>.
<td><a href='#'>删除用户</a></td><td><a href='#'>修改用户</a></td></tr>";
}
echo "</table>";
for($i=1;$i<=$pageCount;$i++){
echo "<a href='empList.php?pageNow=$i'>$i</a> ";
}
mysql_free_result($res);
mysql_free_result($resf);
mysql_close($conn);
?>
</html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>雇员信息列表</title>
</head>
<?php
$conn=mysql_connect("localhost","root","1234") or die(mysql_error());
mysql_query("set names utf8");
mysql_select_db("empmanage",$conn);
$pageSize=3; //每页显示多少条
$rowCount=0; //一共有多少条数据
$pageNow=1; //当前第几页
if(!empty($_GET['pageNow'])){
$pageNow=$_GET['pageNow'];//得到的当前页数
}
$sql="select count(id) from emp"; //获取数据库一个共有多少条数据
$resf=mysql_query($sql);
if($row=mysql_fetch_array($resf)){
$rowCount=$row['0'];
}
$pageCount=ceil($rowCount/$pageSize);//一个多少页
$sql="select * from emp limit ".($pageNow-1)*$pageSize.",".$pageSize."";
$res=mysql_query($sql);
echo "<table width='700px' border='1px'>";
echo "<tr><th>id</th><th>name</th><th>grade</th><th>email</th><th>salary</th><th>删除</th><th>修改</th></tr>";
while($row=mysql_fetch_assoc($res)){
echo "<tr><td>{$row['id']}</td><td>{$row['name']}</td><td>{$row['grade']}</td><td>{$row['email']}</td><td>{$row['salary']}</td>.
<td><a href='#'>删除用户</a></td><td><a href='#'>修改用户</a></td></tr>";
}
echo "</table>";
for($i=1;$i<=$pageCount;$i++){
echo "<a href='empList.php?pageNow=$i'>$i</a> ";
}
mysql_free_result($res);
mysql_free_result($resf);
mysql_close($conn);
?>
</html>