基本功能: 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='Deppartments ')";
- $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> $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." div>"; - }
- 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', '') 或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 ['更新']))
- {
- $EmployeeID=$_POST['number'];
- $收入=$_POST['收入'];
- $outcome=$_POST['結果'];
- if (is_numeric($venue)&&is_numeric($outcome)) //判斷輸入的是否為數字字串
- {
- if($EmployeeID)
- {
- / /修改表格薪資的SQL語句
- $u_sql="更新薪資集InCome=$venue,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 "alert('輸入不正確!');window.location='SY8_2.php';";
- }
- ?>
-
-
複製程式碼
|