基本功能: 1、实现学生基本信息的维护(增删改); 2、实现课程信息的维护(增删改); 3、实现选课的管理(选课、退课); 4、实现成绩管理(录入)、统计学生和课程平均成绩
-
$conn=mysql_connect("localhost","root","123456") or die('连接失败'); //连接服务器
- mysql_select_db("YGGL",$conn) or die('连接数据库失败'); //选择数据库
- mysql_query("SET NAMES 'gb2312'"); //设置字符集
- $Number=@$_GET['Number']; //获取编号
- $Name=@$_GET['Name']; //获取姓名
- $Depart=@$_GET['Depart']; //获取部门名
- //生成查询语句的getsql函数
- function getsql($Num,$Na,$Dep)
- {
- $sql="select * from Employees where ";
- $note=0;
- if($Num)
- {
- //如果填写了编号则在where子句后设置查询条件
- $sql.="EmployeeID like '%$Num%'";
- $note=1;
- }
- if($Na)
- {
- //如果填写了姓名则在$sql后连接查询条件
- if($note==1)
- $sql.=" and Name like '%$Na%'";
- else
- $sql.="Name like '%$Na%'";
- $note=1;
- }
- if($Dep&&($Dep!="所有部门"))
- {
- if($note==1)
- $sql.=" and DepartmentID=(select DepartmentID from Departments
- where DepartmentName='$Dep')";
- else
- {
- $sql.="DepartmentID=(select DepartmentID from Departments
- where DepartmentName='$Dep')";
- $note=1;
- }
- }
- if($note==0)
- {
- //如果什么条件都没设则查询所有记录
- $sql="select * from Employees";
- }
- return $sql; //返回SQL语句
- }
- $sql=getsql($Number,$Name,$Depart); //得到查询语句
- $result=mysql_query($sql);
- $total=mysql_num_rows($result);
- $page=isset($_GET['page'])?$_GET['page']:1; //获取地址栏中page的值,不存在则设为1
- $num=5; //每页显示5条记录
- $url='8_1.php'; //本页URL
- //页码计算
- $pagenum=ceil($total/$num); //获得总页数,也是最后一页
- $page=min($pagenum,$page); //获得首页
- $prepg=$page-1; //上一页
- $nextpg=($page==$pagenum? 0: $page+1); //下一页
- $new_sql=$sql." limit ".($page-1)*$num.",".$num; //查找$num条记录的查询语句
- $new_result=mysql_query($new_sql);
- if($new_row=mysql_fetch_array($new_result))
- {
- //若有查询结果,则以表格形式输出员工信息
- echo "
- 员工信息查询结果
";
- echo "
";- echo "
编号 | ";- echo "
姓名 | ";
- echo "
学历 | ";
- echo "
性别 | ";
- echo "
出生日期 | ";
- echo "
所在部门 |
";
- do
- {
- list($number,$name,$edu,$birthday,$sex,$workyear,$phone,$add,$depid)=$new_row;
- //查找部门名称的SQL语句
- $d_sql="select DepartmentName from Departments where DepartmentID=$depid"; $d_result=mysql_query($d_sql);
- $d_row=mysql_fetch_row($d_result);
- echo "
$number | "; //输出编号- echo "
$name | "; //输出姓名
- echo "
$edu | "; //输出学历
- if($sex=='1')
- echo "
男 | ";
- else
- echo "
女 | ";
- $timeTemp=strtotime($birthday); //将日期时间解析为 UNIX 时间戳
- $date=date("Y-n-j",$timeTemp); //用date函数将时间转换为“年-月-日”形式
- echo "
$date | "; //输出出生日期
- echo "
$d_row[0] | "; //输出所在部门的名称
- echo "
";
- }while($new_row=mysql_fetch_array($new_result));
- echo "
";
- //开始分页导航条代码
- $pagenav="";
- if($prepg)
- $pagenav.="
- 上一页
";
- for($i=1;$i {
- if($page==$i) $pagenav.=$i." ";
- else
- $pagenav.="
- $i
";
- }
- if($nextpg)
- $pagenav.="
- 下一页
";
- $pagenav.="共(".$pagenum.")页";
- //输出分页导航
- echo "
".$pagenav." ";
- }
- else
- echo "<script>alert('无记录!');location.href='8_1.php';</script>";
- ?>
-
复制代码
-
-
- 员工信息查询
-
-
员工信息查询
-
@include "SY8_1_search.php"; //包含SY8_1_search.php页面
- ?>
-
-
-
复制代码
-
-
- 员工收入页面
-
-
员工收入情况
-
@include "SY8_2_pro.php"; //包含SY8_2_pro.php页面
- ?>
-
-
-
复制代码
-
$Number=$_POST['Number'];
- $conn=mysql_connect('localhost', 'root', '') or die("连接失败");
- mysql_select_db("YGGL",$conn); //打开数据库
- $s_sql="select * from Salary where EmployeeID='$Number'";
- $s_result=mysql_query($s_sql,$conn);
- $s_row=mysql_fetch_array($s_result);
- $id=@$s_row['EmployeeID'];
- $in=@$s_row['InCome'];
- $out=@$s_row['OutCome'];
- @$realcom=$in-$out;
- ?>
-
-
-
-
-
if(isset($_POST['update']))
- {
- $EmployeeID=$_POST['number'];
- $income=$_POST['income'];
- $outcome=$_POST['outcome'];
- if(is_numeric($income)&&is_numeric($outcome)) //判断输入的是否是数字字符串
- {
- if($EmployeeID)
- {
- //修改表salary的SQL语句
- $u_sql="update salary set InCome=$income,OutCome=$outcome
- where EmployeeID='$EmployeeID'";
- $u_result=mysql_query($u_sql);
- if(mysql_rows_affected($conn)!=0)
- echo "<script>alert('修改成功!');window.location='SY8_2.php';</script>";
- }
- else
- echo "<script>alert('未获得编号!');window.location='SY8_2.php';</script>";
- }
- else
- echo "<script>alert('输入不正确!');window.location='SY8_2.php';</script>";
- }
- ?>
-
复制代码
|