-
Notifications
You must be signed in to change notification settings - Fork 0
/
csearch.php
81 lines (66 loc) · 1.67 KB
/
csearch.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
<?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;
}
</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 Course 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";
$c_id="";
if(isset($_POST["search_id"])){
$c_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 c_id,c_name,cradit FROM course where c_id ='$c_id'";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
echo "<tr><th><center>Course id</th><th>Course name</th><th>Cradit Hour</th></tr>";
while($row = mysqli_fetch_assoc($result)) {
echo "<tr>";
echo "<td>". $row["c_id"]. "</td><td>". $row["c_name"]."</td><td>" . $row["cradit"]."</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';?>