06-php雇员管理系统-实现显示雇员信息列表分页改进(可以处理大数据100000条)
2013-08-13 01:31
901 查看
empList.php
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="content-type">
<title>雇员信息列表</title>
</head>
<?php
$conn = mysql_connect ( "localhost", "root", "root" ) or die ( mysql_error () );
mysql_query ( "set names utf8" );
//选择数据库
mysql_select_db ( "test", $conn );
$pageSize = 20; //每页数
$rowCount = 0; //记录数
$pageNow = 1; //当前页
$pageCount = 0; //页数
//根据用户的点击收取pagenow的值
if (! empty ( $_GET ['pageNow'] )) {
$pageNow = $_GET ['pageNow'];
}
//查找数据库中总的记录有多少条
$sql = "select count(id) from emp";
$res1 = mysql_query ( $sql );
//取出记录数
if ($row = mysql_fetch_row ( $res1 )) {
$rowCount = $row [0];
}
//计算共有多少页
$pageCount = ceil ( $rowCount / $pageSize );
//分页查找数据库中的记录
$sql = "select * from emp limit " . ($pageNow - 1) * $pageSize . ",$pageSize";
$res2 = mysql_query ( $sql, $conn );
//表格显示分页查询后的结果
echo "<table width='700px' border='1px' bordercolor='green' cellspacing='0px'>";
echo "<tr><th>id</th><th>name</th><th>grade</th>";
echo "<th>email</th><th>salary</th><th>删除</th><th>修改</th></tr>";
//这里我们需要循环显示用户的信息
while ( $row = mysql_fetch_assoc ( $res2 ) ) {
echo "<tr><td>{$row['id']}</td><td>{$row['name']}</td><td>{$row['grade']}</td>";
echo "<td>{$row['email']}</td><td>{$row['salary']}</td>";
echo "<td><a href='#'>删除用户</a></td>";
echo "<td><a href='#'>修改用户</a></td><tr>";
}
echo "<h1>雇员信息列表</h1>";
echo "<hr/>";
echo "</table>";
//打印页码的超链接
//for($i = 1; $i <= $pageCount; $i ++) {
// echo "<a href='empList.php?pageNow=$i'>$i</a> ";
//}
//显示上一页和下一页
if ($pageNow > 1) {
$prePage = $pageNow - 1;
echo "<a href='empList.php?pageNow=$prePage'>上一页</a> ";
}
if ($pageNow < $pageCount) {
$nextPage = $pageNow + 1;
echo "<a href='empList.php?pageNow=$nextPage'>下一页</a> ";
}
//显示当前页和共有多少页
echo "当前页{$pageNow}/共{$pageCount}页";
//指定跳转到某页
echo "<br/><br/>";
?>
<form action="empList.php" method="get" onsubmit="checkNum();">跳转到:<input
type="text" name="pageNow" style="width:40px;"/>页 <input type="submit" value="Go" />
</form>
<?php
//关闭资源
mysql_free_result ( $res2 );
mysql_close ( $conn );
?>
</html>empManage.php
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
</head>
<?php
echo "欢迎你," . $_GET ['name'] . "登录成功!...";
echo "<br/><a href='login.php'>返回重新登录</a>";
?>
<h1>主界面</h1>
<a href="empList.php">管理用户</a>
<br />
<a href="#">添加用户</a>
<br />
<a href="#">查询用户</a>
<br />
<a href="#">退出系统</a>
<br />
</html>
login.php
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="content-type">
</head>
<h1>管理员登录系统</h1>
<form action="loginProcess.php" method="post">
<table>
<tr>
<td>用户id</td>
<td><input type="text" name="id" /></td>
</tr>
<tr>
<td>密 码</td>
<td><input type="password" name="password" /></td>
</tr>
<tr>
<td><input type="submit" value="用户登录" /></td>
<td><input type="reset" value="重新填写" /></td>
</tr>
</table>
</form>
<?php
if (! empty ( $_GET ['errno'] )) {
$errno = $_GET ['errno'];
if ($errno == 1) {
echo "<font color='red' size='3'>你的用户名或密码错误</font>";
}
}
?>
</html>
loginProcess.php
<?php
//接受用户的数据
//1.id
$id = $_POST ['id'];
//2.密码
$password = $_POST ['password'];
//得到连接
$conn = mysql_connect ( "localhost", "root", "root" );
if (! $conn) {
die ( "连接失败" . mysql_errno () );
}
//设置访问数据库的编码
mysql_query ( "set names utf8", $conn ) or die ( mysql_errno () );
//选择数据库
mysql_select_db ( "test", $conn ) or die ( mysql_errno () );
//发送sql语句验证
$sql = "select password,name from admin where id=$id";
//通过id获取password
$res = mysql_query ( $sql, $conn );
if ($row = mysql_fetch_assoc ( $res )) {
//取出数据库的密码
if ($row ['password'] == md5 ( $password )) {
//合法
//取出用户名字
$name=$row['name'];
header ( "Location:empManage.php?name=$name" );
exit ();
}
}
header ( "Location:login.php?errno=1" );
exit ();
//关闭资源
mysql_free_result($res);
mysql_close($conn);
?>
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="content-type">
<title>雇员信息列表</title>
</head>
<?php
$conn = mysql_connect ( "localhost", "root", "root" ) or die ( mysql_error () );
mysql_query ( "set names utf8" );
//选择数据库
mysql_select_db ( "test", $conn );
$pageSize = 20; //每页数
$rowCount = 0; //记录数
$pageNow = 1; //当前页
$pageCount = 0; //页数
//根据用户的点击收取pagenow的值
if (! empty ( $_GET ['pageNow'] )) {
$pageNow = $_GET ['pageNow'];
}
//查找数据库中总的记录有多少条
$sql = "select count(id) from emp";
$res1 = mysql_query ( $sql );
//取出记录数
if ($row = mysql_fetch_row ( $res1 )) {
$rowCount = $row [0];
}
//计算共有多少页
$pageCount = ceil ( $rowCount / $pageSize );
//分页查找数据库中的记录
$sql = "select * from emp limit " . ($pageNow - 1) * $pageSize . ",$pageSize";
$res2 = mysql_query ( $sql, $conn );
//表格显示分页查询后的结果
echo "<table width='700px' border='1px' bordercolor='green' cellspacing='0px'>";
echo "<tr><th>id</th><th>name</th><th>grade</th>";
echo "<th>email</th><th>salary</th><th>删除</th><th>修改</th></tr>";
//这里我们需要循环显示用户的信息
while ( $row = mysql_fetch_assoc ( $res2 ) ) {
echo "<tr><td>{$row['id']}</td><td>{$row['name']}</td><td>{$row['grade']}</td>";
echo "<td>{$row['email']}</td><td>{$row['salary']}</td>";
echo "<td><a href='#'>删除用户</a></td>";
echo "<td><a href='#'>修改用户</a></td><tr>";
}
echo "<h1>雇员信息列表</h1>";
echo "<hr/>";
echo "</table>";
//打印页码的超链接
//for($i = 1; $i <= $pageCount; $i ++) {
// echo "<a href='empList.php?pageNow=$i'>$i</a> ";
//}
//显示上一页和下一页
if ($pageNow > 1) {
$prePage = $pageNow - 1;
echo "<a href='empList.php?pageNow=$prePage'>上一页</a> ";
}
if ($pageNow < $pageCount) {
$nextPage = $pageNow + 1;
echo "<a href='empList.php?pageNow=$nextPage'>下一页</a> ";
}
//显示当前页和共有多少页
echo "当前页{$pageNow}/共{$pageCount}页";
//指定跳转到某页
echo "<br/><br/>";
?>
<form action="empList.php" method="get" onsubmit="checkNum();">跳转到:<input
type="text" name="pageNow" style="width:40px;"/>页 <input type="submit" value="Go" />
</form>
<?php
//关闭资源
mysql_free_result ( $res2 );
mysql_close ( $conn );
?>
</html>empManage.php
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
</head>
<?php
echo "欢迎你," . $_GET ['name'] . "登录成功!...";
echo "<br/><a href='login.php'>返回重新登录</a>";
?>
<h1>主界面</h1>
<a href="empList.php">管理用户</a>
<br />
<a href="#">添加用户</a>
<br />
<a href="#">查询用户</a>
<br />
<a href="#">退出系统</a>
<br />
</html>
login.php
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="content-type">
</head>
<h1>管理员登录系统</h1>
<form action="loginProcess.php" method="post">
<table>
<tr>
<td>用户id</td>
<td><input type="text" name="id" /></td>
</tr>
<tr>
<td>密 码</td>
<td><input type="password" name="password" /></td>
</tr>
<tr>
<td><input type="submit" value="用户登录" /></td>
<td><input type="reset" value="重新填写" /></td>
</tr>
</table>
</form>
<?php
if (! empty ( $_GET ['errno'] )) {
$errno = $_GET ['errno'];
if ($errno == 1) {
echo "<font color='red' size='3'>你的用户名或密码错误</font>";
}
}
?>
</html>
loginProcess.php
<?php
//接受用户的数据
//1.id
$id = $_POST ['id'];
//2.密码
$password = $_POST ['password'];
//得到连接
$conn = mysql_connect ( "localhost", "root", "root" );
if (! $conn) {
die ( "连接失败" . mysql_errno () );
}
//设置访问数据库的编码
mysql_query ( "set names utf8", $conn ) or die ( mysql_errno () );
//选择数据库
mysql_select_db ( "test", $conn ) or die ( mysql_errno () );
//发送sql语句验证
$sql = "select password,name from admin where id=$id";
//通过id获取password
$res = mysql_query ( $sql, $conn );
if ($row = mysql_fetch_assoc ( $res )) {
//取出数据库的密码
if ($row ['password'] == md5 ( $password )) {
//合法
//取出用户名字
$name=$row['name'];
header ( "Location:empManage.php?name=$name" );
exit ();
}
}
header ( "Location:login.php?errno=1" );
exit ();
//关闭资源
mysql_free_result($res);
mysql_close($conn);
?>
相关文章推荐
- 05-php雇员管理系统-实现显示雇员信息列表分页
- 04-php雇员管理系统-实现显示雇员信息列表
- 通用权限管理系统组件 (GPM - General Permissions Manager) 中实现大数据的高效分页显示
- 使用PHP制作 简易员工管理系统之五(分页显示用户信息)
- 07-php雇员管理系统-分层模式实现登录,分页
- C语言实现一个Window控制台带彩色,且可以用方向键选择并确认的菜单式列表(二) ---学生信息管理系统
- 08-php雇员管理系统-分层模式实现通用分页
- 通用权限管理系统组件 (GPM - General Permissions Manager) 中实现大数据的高效分页显示
- 03-php雇员管理系统-实现显示用户名称
- 使用PHP制作 简易员工管理系统之六(采用分层分页显示用户信息)
- 通用权限管理系统组件 (GPM - General Permissions Manager) 中实现大数据的高效分页显示
- 学生社团管理系统 任务:通过此系统可以实现如下功能(包含但不限于以下功能,可自行设计): 1、社团信息包括:社团编号、社团名称、成立时间…… 2、学生信息包括:学号、姓名、性别、年级、专业…… 3
- jq.ajax+php+mysql实现分页显示数据
- jdbc,数据库案例:客户信息管理系统:jsp部分,数据库数据封装类,dao接口和实现
- 字符串处理是许多程序中非常重要的一部分,它们可以用于文本显示,数据表示,查找键和很多目的.在Unix下,用户可以使用正则表达式的强健功能实现这些 目的,从Java1.4起,Java核心API就引入了java.util.regex程序包,它是一种有价值的基础
- 如何在施工物料管理Web系统中处理大量数据并显示
- 图书管理系统之过滤器--处理用户信息的过滤和订单数据的处理
- jQuery+Ajax+PHP+Mysql实现分页显示数据
- 家庭财务管理系统实战3- 实现列表数据的增删改查功能
- 处理大数据分页下拉列表显示方式