-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearching data.php
40 lines (31 loc) · 1.09 KB
/
searching data.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
<?php
$host ="localhost";
$dbusername="db_username";
$dbpassword="password";
$dbname="dbname";
$conn = new mysqli($host,$dbusername,$dbpassword,$dbname);
if ($conn->connect_error){
die ("connection failed:" . $conn->connect_error);
}
if(isset($_POST['search']))
{
$id=$_POST['id'];
$sql = "SELECT School,firstname,ID, lastname,username,Grade FROM studentdata where firstname LIKE '%{$id}%' OR lastname LIKE '%{$id}%' OR username LIKE '%{$id}%'";
$result = $conn->query($sql);
echo "<center><table><tr><th>School Name</th><th>Student ID</th><th>First Name</th><th>Last Name</th><th>Username</th><th>Grade</th><th>Action</th></tr>";
// output data of each rowd Displaying table on website
while($row = $result->fetch_assoc()) {
echo "<tr><td>". $row["School"].
"<td>". $row["ID"].
"<td>" . $row["firstname"].
"<td>" . $row["lastname"] .
"<td>". $row["username"] .
"<td>".$row["Grade"]. "</td></tr>" ;
}
echo "</table></center>";
} else
{
echo " DATA DIDNT MATCH IN OUR DATABASE";
}
$conn->close();
?>