-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
125 lines (107 loc) · 2.95 KB
/
search.php
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<?php include'header.php';?>
<html>
<head>
<style>
body {
background-image: url('b.jpg');
background-size: cover;
}
table{ width: 800px;
margin:auto;
text-align:center;
margin-top:30px;
color: #ffff; }
table,th,td{
border:3px solid gray;
border-collapse:collapse;
padding:15px;
font-size:15px;
}
table1{ width: 800px;
margin:auto;
text-align:center;
margin-top:30px;
color: #ffff; }
table,th,td{
border:3px solid gray;
border-collapse:collapse;
padding:15px;
font-size:15px;
}
</style>
</head>
<?php ?>
<center>
<form method="POST" style="text-align:center">
<h3 style="font-size:150%;">Search Form</h3>
<input type="text" style="font-size:100%;"placeholder="Search by Student id"; name="search_id"><br>
<br>
<button class="button" ><b><big>Search</big></button>
<br><br>
</form>
</center>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "std";
$id="";
if(isset($_POST["search_id"])){
$id=$_POST["search_id"];
}
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "SELECT id,name,dep,area FROM tb_std where id='$id'";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
echo "<table>";
echo "<tr><th><center>Id</th><th>Name</th><th>Department</th><th>Area</th></tr>";
while($row = mysqli_fetch_assoc($result)) {
echo "<tr>";
echo "<td>". $row["id"]. "</td><td>". $row["name"]. "</td><td>". $row["dep"]."</td><td>" . $row["area"]."</td>";
echo "</tr>";
}
echo "</table>";
}
?>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "std";
$id="";
if(isset($_POST["search_id"])){
$id=$_POST["search_id"];
}
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "SELECT tb_std.id,courselist.c_id,tb_faculty.f_name,course.c_name FROM tb_std INNER join courselist on tb_std.id = courselist.id INNER join tb_faculty on tb_faculty.f_id = courselist.f_id inner join course on courselist.c_id = course.c_id where tb_std.id='$id'";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
echo "<table>";
echo "<tr><th><center>Faculty Name</th><th>Course ID</th><th>Course name</th></tr>";
while($row = mysqli_fetch_assoc($result)) {
echo "<tr>";
echo "<td>". $row["f_name"]. "</td><td>". $row["c_id"]."</td><td>" . $row["c_name"]."</td>";
echo "</tr>";
}
echo "</table>";
} else {
echo "<h2><font color='black'>No Data Found </font></h2>";
}
mysqli_close($conn);
?>
</center>
<?php ?>
</html>
<?php include'footer.php';?>