Basic functions: 1. maintain basic information of students (add, delete, modify, and delete); 2. maintain course information (add, delete, modify, and delete course information ); 3. course selection management (course selection and course withdrawal); 4. score management (entry), Statistics, and average course score
- $ Conn = mysql_connect ("localhost", "root", "123456") or die ('connection failed'); // connect to the server
- Mysql_select_db ("YGGL", $ conn) or die ('database connection failed'); // select a database
- Mysql_query ("set names 'gb2312 '"); // sets the character SET.
- $ Number = @ $ _ GET ['Number']; // GET the Number
- $ Name = @ $ _ GET ['name']; // GET the Name
- $ Depart = @ $ _ GET ['demo']; // Obtain the department name.
- // Generate the getsql function of the query statement
- Function getsql ($ Num, $ Na, $ Dep)
- {
- $ SQL = "select * from Employees where ";
- $ Note = 0;
- If ($ Num)
- {
- // If the number is entered, set the query condition after the where clause
- $ SQL. = "EmployeeID like '% $ Num % '";
- $ Note = 1;
- }
- If ($ Na)
- {
- // If the name is entered, the query conditions are connected 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 between mentid = (select between mentid from orders ments
- Where DepartmentName = '$ dep ')";
- Else
- {
- $ SQL. = "explain mentid = (select distinct mentid from orders ments
- Where DepartmentName = '$ dep ')";
- $ Note = 1;
- }
- }
- If ($ note = 0)
- {
- // If no conditions are set, all records are queried.
- $ SQL = "select * from Employees ";
- }
- Return $ SQL; // return an SQL statement
- }
- $ SQL = getsql ($ Number, $ Name, $ Depart); // Obtain the query statement.
- $ Result = mysql_query ($ SQL );
- $ Total = mysql_num_rows ($ result );
- $ Page = isset ($ _ GET ['Page'])? $ _ GET ['Page']: 1; // GET the page value in the address bar. if the page does not exist, set it to 1.
- $ Num = 5; // 5 records are displayed on each page
- $ Url = '8 _ 1. php'; // URL of the current page
- // Page number calculation
- $ Pagenum = ceil ($ total/$ num); // obtain the total number of pages, which is also the last page.
- $ Page = min ($ pagenum, $ page); // Get the homepage
- $ Prepg = $ page-1; // Previous page
- $ Nextpg = ($ page = $ pagenum? 0: $ page + 1); // Next page
- $ New_ SQL = $ SQL. "limit". ($ page-1) * $ num. ",". $ num; // query statements for $ num records
- $ New_result = mysql_query ($ new_ SQL );
- If ($ new_row = mysql_fetch_array ($ new_result ))
- {
- // If there is a query result, the employee information is output in the form of a table
- Echo"
- Employee Information query result
";
- Echo"
- Echo"
- Echo"
- Echo"
- Echo"
- Echo"
- Echo"
- Do
- Echo"
- Echo"
- If ($ sex = '1 ')
- Else
- $ TimeTemp = strtotime ($ birthday); // Parse the date and time as a UNIX timestamp
- Echo"
- Echo"
- } While ($ new_row = mysql_fetch_array ($ new_result ));
- {
- List ($ number, $ name, $ edu, $ birthday, $ sex, $ workyear, $ phone, $ add, $ depid) = $ new_row;
- // Query the SQL statement of the department name
- $ D_ SQL = "select DepartmentName from orders ments where orders mentid = $ depid"; $ d_result = mysql_query ($ d_ SQL );
- $ D_row = mysql_fetch_row ($ d_result );
- Echo"
- Echo"
- Echo"
- $ Date = date ("Y-n-j", $ timeTemp); // use the date function to convert the time to the "year-month-day" format.
- Echo"
- Echo"
";
No. | ";
Name | ";
Education level | ";
Gender | ";
Date of birth | ";
Department |
";
$ Number | "; // Output number
$ Name | "; // Output name
$ Edu | "; // Output degree
Male | ";
Female | ";
$ Date | "; // Output the date of birth
$ D_row [0] | "; // Output the name of the department
";
";
- // Start the paging navigation bar code
- $ Pagenav = "";
- If ($ prepg)
- $ Pagenav. ="
- Previous page ";
- For ($ I = 1; $ I <= $ pagenum; $ I ++)
- {
- If ($ page = $ I) $ pagenav. = $ I ."";
- Else
- $ Pagenav. ="
- $ I ";
- }
- If ($ nextpg)
- $ Pagenav. ="
- Next page ";
- $ Pagenav. = "total (". $ pagenum. ") page ";
- // Output paging navigation
- Echo"
". $ Pagenav ." ";
- }
- Else
- Echo "script" alert ('No record! '); Location. href = '8 _ 1. php'; script ";
- ?>
- Employee Information Query
Employee Information Query
- @ Include "sy8_mongosearch.php"; // contains the sy8_mongosearch.php page.
- ?>
- Employee income page
Employee income
- @ Include "SY8_2_pro.php"; // contains the SY8_2_pro.php page.
- ?>
- $ Number = $ _ POST ['Number'];
- $ Conn = mysql_connect ('localhost', 'root', '') or die (" connection failed ");
- Mysql_select_db ("YGGL", $ conn); // open the database
- $ 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 ['Welcome '];
- $ Out = @ $ s_row ['outcome '];
- @ $ Realcom = $ in-$ out;
- ?>
- If (isset ($ _ POST ['update'])
- {
- $ EmployeeID = $ _ POST ['Number'];
- $ Income = $ _ POST ['Welcome '];
- $ Outcome = $ _ POST ['outcome '];
- If (is_numeric ($ income) & is_numeric ($ outcome) // determines whether the input is a numeric string
- {
- If ($ EmployeeID)
- {
- // Modify the SQL statement of table salary
- $ 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 ('modification successful! '); Window. location = 'sy8 _ 2. php'; script ";
- }
- Else
- Echo "script" alert ('no number is obtained! '); Window. location = 'sy8 _ 2. php'; script ";
- }
- Else
- Echo "script" alert ('The input is incorrect! '); Window. location = 'sy8 _ 2. php'; script ";
- }
- ?>
|