I'm trying to pull information from a 'SQL' database via a 'SUBMIT' form. The connection is made I presume as it's the same code as for the entry and that works just fine. I can display the result as a block of items but not integrate it in a table.
For now as the code is, it just returns a blank page...
I find many examples from a couple years ago but things have changed since..
Here is the code on the PHP page that should display the results in a table.
I've tried different ways of integrating the results to a table before coming here for help but all return the same result. I am fairly new to this.
<?php
$servername = "localhost";
$username = "root";
$password = "Rmvs03ff";
$dbname = "EmployeeListing";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if (isset($_POST['submit-search'])) {
$search = mysqli_real_escape_string($conn, $_POST['search']);
$sql = "SELECT * FROM BasicEmployee WHERE EmployeeID LIKE '%$search%' OR FirstName LIKE '%$search%' OR LastName LIKE '%$search%' OR DoB LIKE '%$search%'";
$result = mysqli_query($conn, $sql);
$queryResult = mysqli_num_rows($result);
echo "<br/>There are " .$queryResult. " matches found";
echo "<table>
<tr>
<th>Employee I.D.</th>
<th>Sex</th>
<th>First Name</th>
<th>Last Name</th>
<th>Date of Birth</th>
</tr>";
if ($queryResult > 0) {
while ($row = mysqli_fetch_assoc($result)) {
echo "<tr>"
echo "<td><strong>
".$row['EmployeeID']."
</strong></td>"
echo "<td>
".$row['Prefix']."
</td>"
echo "<td><p>
".$row['FirstName']."
</p></td>"
echo "<td><p>
".$row['LastName']."
</p></td>"
echo "<td><p>
".$row['DoB']."
</p></td>";
echo "</table>";
}
} else {
echo "<br/>No results found";
}
}
echo "<br/>Approved";
$conn->close();
?>
</body>
</html>
I do have the opening html, head an bodies of course, didn't want to block up space with this...