<h1>SEARCH PAGE</h1>
<div class="container">
<div class="card-body">
<table id="example2" class="table table-bordered table-hover">
<thead>
<tr>
<th>profile Image</th>
<!-- <th>first name</th> -->
<th>first name</th>
<th>last name</th>
<th>username</th>
<th>email</th>
</tr>
</thead>
<tbody>
<?php
//connecting to database
$dbserver = "localhost";
$dbusername = "root";
$dbpassword = "";
$dbname = "login";
$conn = mysqli_connect($dbserver, $dbusername, $dbpassword, $dbname);
//fetching search results from database
if (isset($_POST['submit-search'])) {
$search = mysqli_real_escape_string($conn, $_POST['search']);
$sql = "SELECT * FROM users WHERE image LIKE '%$search%' OR fname LIKE '%$search%' OR lname LIKE '%$search%' OR username LIKE '%$search%' OR email LIKE '%$search%'";
$result = mysqli_query($conn, $sql);
$queryResult = mysqli_num_rows($result);
echo "There are ".$queryResult."results!";
if ($queryResult > 0) {
while ($row = mysqli_fetch_assoc($result)) {
//displaying search results on the search page
echo "<tr>
<td><img src='images/".$row['image']."' height='200px' width='200px'> </td>
<td>".$row['fname']. "</td>
<td>".$row['lname']. "</td>
<td>".$row['username']. "</td>
<td>".$row['email']. "</td>
</tr>";
}
}
else {
echo "there are no result matching your search";
}
}
?>
</tbody>
</table>
</div>
</div>
<div class="container">
<div class="card-body">
<table id="example2" class="table table-bordered table-hover">
<thead>
<tr>
<th>profile Image</th>
<!-- <th>first name</th> -->
<th>first name</th>
<th>last name</th>
<th>username</th>
<th>email</th>
</tr>
</thead>
<tbody>
<?php
//connecting to database
$dbserver = "localhost";
$dbusername = "root";
$dbpassword = "";
$dbname = "login";
$conn = mysqli_connect($dbserver, $dbusername, $dbpassword, $dbname);
//fetching search results from database
if (isset($_POST['submit-search'])) {
$search = mysqli_real_escape_string($conn, $_POST['search']);
$sql = "SELECT * FROM users WHERE image LIKE '%$search%' OR fname LIKE '%$search%' OR lname LIKE '%$search%' OR username LIKE '%$search%' OR email LIKE '%$search%'";
$result = mysqli_query($conn, $sql);
$queryResult = mysqli_num_rows($result);
echo "There are ".$queryResult."results!";
if ($queryResult > 0) {
while ($row = mysqli_fetch_assoc($result)) {
//displaying search results on the search page
echo "<tr>
<td><img src='images/".$row['image']."' height='200px' width='200px'> </td>
<td>".$row['fname']. "</td>
<td>".$row['lname']. "</td>
<td>".$row['username']. "</td>
<td>".$row['email']. "</td>
</tr>";
}
}
else {
echo "there are no result matching your search";
}
}
?>
</tbody>
</table>
</div>
</div>