Basic functions: 1. Realize the maintenance of students’ basic information (add, delete and modify); 2. Realize the maintenance of course information (add, delete and modify); 3. Realize the management of course selection (course selection, withdrawal); 4. Realize the performance management (entry), Statistics on student and course average grades
- $conn=mysql_connect("localhost","root","123456") or die('Connection failed'); //Connect to the server
- mysql_select_db("YGGL",$conn) or die('Failed to connect to database'); //Select database
- mysql_query("SET NAMES 'gb2312'"); //Set character set
- $Number=@$_GET['Number']; //Get number
- $Name =@$_GET['Name']; //Get the name
- $Depart=@$_GET['Depart']; //Get the department name
- //The getsql function that generates the query statement
- function getsql($Num,$Na ,$Dep)
- {
- $sql="select * from Employees where ";
- $note=0;
- if($Num)
- {
- //If the number is filled in, set the query conditions after the where clause
- $ sql.="EmployeeID like '%$Num%'";
- $note=1;
- }
- if($Na)
- {
- //If the name is filled in, connect the query conditions after $sql
- if($note ==1)
- $sql.=" and Name like '%$Na%'";
- else
- $sql.="Name like '%$Na%'";
- $note=1;
- }
- if( $Dep&&($Dep!="All Departments"))
- {
- 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)
- {
- / /If no conditions are set, query all records
- $sql="select * from Employees";
- }
- return $sql; //Return SQL statement
- }
- $sql=getsql($Number,$Name,$Depart ); //Get the query statement
- $result=mysql_query($sql);
- $total=mysql_num_rows($result);
- $page=isset($_GET['page'])?$_GET['page']: 1; //Get the value of page in the address bar, if it does not exist, set it to 1
- $num=5; //Display 5 records per page
- $url='8_1.php'; //URL of this page
- // Page number calculation
- $pagenum=ceil($total/$num); //Get the total page number, which is also the last page
- $page=min($pagenum,$page); //Get the home page
- $prepg=$page- 1; //Previous page
- $nextpg=($page==$pagenum? 0: $page+1); //Next page
- $new_sql=$sql." limit ".($page-1)* $num.",".$num; //Query statement to find $num records
- $new_result=mysql_query($new_sql);
- if($new_row=mysql_fetch_array($new_result))
- {
- //If there is a query As a result, employee information will be output in table form
- echo "
- Employee information query results echo "
";
- echo "
number |
- echo "
Name | ";
- echo "
Education | ";
- echo "
Gender | ";
- echo "
Date of Birth | ";
- echo "
Department | ";
- do
- {
- list($number,$name,$edu ,$birthday,$sex,$workyear,$phone,$add,$depid)=$new_row;
- //SQL statement to find department name
- $d_sql="select DepartmentName from Departments where DepartmentID=$depid"; $d_result =mysql_query($d_sql);
- $d_row=mysql_fetch_row($d_result);
- echo "
$number | "; //Output number
- echo "
$name< /td>"; //Output name
- echo "
$edu | "; //Output academic qualifications
- if($sex=='1')
- echo "
Male td>";
- else
- echo "
Female | ";
- $timeTemp=strtotime($birthday); //Parse the date and time into a UNIX timestamp
- $date=date("Y-n-j" ,$timeTemp); //Use the date function to convert the time into "year-month-day" format
- echo "
$date | "; //Output the date of birth
- echo "
$ d_row[0] | "; //Output the name of the department
- echo "
| | ";
- }while($new_row=mysql_fetch_array($new_result));
- echo "
";
- //Start paging navigation bar code
- $pagenav="";
- if($prepg)
- $pagenav.="< ;a href='$url?page=$prepg&Number=$Number&Name=$Name&Depart=$Depart'>
- Previous page ";
- for($i=1;$i<=$pagenum; $i++)
- {
- if($page==$i) $pagenav.=$i." ";
- else
- $pagenav.="
- $i ";
- }
- if($nextpg)
- $pagenav.="
- Next page";
- $pagenav.="Total (".$pagenum.") pages";
- //Output paging navigation
- echo "
< div align=center class=STYLE1>".$pagenav." ";
}
else
echo "<script>alert('No record!'); location.href='8_1.php';</script>";
?>
Copy code
- Employee information query
- < /style>
Employee Information Query
- @include "SY8_1_search.php"; //Contains the SY8_1_search.php page
- ?>
- < ;/html>
-
Copy code
- 员工收入页面
员工收入情况
- @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>";
- }
- ?>
-
复制代码
|