-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstaff.php
More file actions
75 lines (61 loc) · 2.43 KB
/
staff.php
File metadata and controls
75 lines (61 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<!DOCTYPE HTML>
<html>
<head>
<title> Using staff details </title>
<link rel="stylesheet" href="style.css" />
</head>
<body bgcolor="white">
<h1> Staff search conditions </h1>
<?php
$formtop='<form <action="<?php echo htmlentities($_SERVER[$redir]); ?>" method="post">';
$menu=$formtop.'<select name="second" style="display: none"> <option value=""></option></select>';
$subbutton='<input type="submit" name="formSubmit" value="Submit" /></form><a href="index.html"> Back to index </a>';
$formdetail="";
$query="";
$wherecond="";
$result_id="";
if(isset($_POST['formSubmit'])) {$query= $_POST['first'];
$wherecond= $_POST['second'];}
$conn_id = @mysql_connect ("server", "id","password")
or exit ();
mysql_select_db ("Dreamhome_km32", $conn_id);
if (!$query && !$wherecond){
$formdetail.=$menu.'
<label for="first">Please choose how you like to search :</label><br>
<select name="first">
<option value="">Select an option...</option>
<option value="Sno">Staff Number</option>
<option value="Position">Position</option>
<option value="Bno">Branch Number</option>
</select>
<br>'.$subbutton;
}
if ($query && !$wherecond){
Printf("Showing search results for : ".$query);
$result_id = mysql_query ("select FName, LName, " .$query. " from staff") or exit ();
if ($result_id){
while ($row = mysql_fetch_array ($result_id)){
printf ("<p> ".$row["FName"]." ".$row["LName"]." " .$row[$query] ); }
$menu=$formtop.'<select name="first" style="display: none">
<option value='.$query.'></option>
</select>';
$result_id = mysql_query ("select FName, LName," .$query. " from staff group by ".$query) or exit ();
$menu.="<label for='second'> Search parameters : </label> <select name='second'><option value=''>Select an option...</option>";
while ($row = mysql_fetch_array ($result_id)){
$menu.="<option value=".$row[$query].">".$row[$query]."</option>";
}
$menu.=$subbutton;
mysql_free_result ($result_id);
}
}
elseif ($query && $wherecond){
Printf("Showing search results for : ".$query. " and ".$wherecond);
$result_id = mysql_query ("select * from staff where ".$query." = '".$wherecond."'") or exit ();
while ($row = mysql_fetch_array ($result_id)){
printf ("<p> ".$row["FName"]." ".$row["LName"]." " .$row[$query] );}
mysql_free_result ($result_id);}
?>
<span><?php printf( $formdetail); ?> </span>
<span><?php printf( $menu); ?> </span>
</body>
</html>