I had a page loading data from my mysql database working and showing the data correctly, but after attempting to implement a search function there is now an error attempting to load the page.
Below is my html code I added for the search bar (this is in the file PhysicianSearch.php):
<form action="PhysicianSearch.php" method="post">
<input type="text" placeholder="Search.." name="ValueToSearch">
<input type="submit" name="search" value="Filter"><br><br>
</form>
below is the php code I added for the search bar (this is in the file PhysicianSearch.php):
<?php
if(isset($_POST['search'])) {
$valueToSearch = $_POST['valueToSearch'];
$query = "SELECT * FROM Physician WHERE CONCAT('physicianID', 'firstName', 'lastName', 'yearNum', 'yearNum', 'position', 'isAttending', 'highRiskTrained') LIKE '%" . $valueToSearch ."%'";
$search_result = filterTable($query);
} else {
$query = "select * from Physician";
$search_result = filterTable($query);
}
function filterTable($query) {
$connect = mysqli_connect("localhost", "root", "password", "dbName");
$filter_results = mysqli_query($connect, $query);
return $filter_results
}
?>