I have a simple html table being populated by my mysql database, and a function that is creating a new query in php, that will then be loaded into the query which is used to populate the table as a means of filtering it down. The issue becomes that when there is a value of NULL
in my database instead of just being an empty value, it breaks the statement.
Below is the value to generate the SQL which will populate the table after filtering:
<?php
if(isset($_POST['search'])) {
$valueToSearch = $_POST['valueToSearch'];
$query = "SELECT * FROM PatientEventLog WHERE CONCAT(`patientEventLogID`, `patientEventID`, `patientID`, `eventCreatorID`, `eventEdited`, `antibiotic`, `waterBroke`, `vertex`, `cervixDilation`, `effacedPercent`, `station`, `membranes`, `analgesia`, `augment`, `notes`, `visible`) LIKE '%" . $valueToSearch ."%'";
echo "value to search: \n";
echo $valueToSearch;
echo "\n \n above search resluts";
echo $query;
echo "below search results";
$search_result = filterTable($query);
} else {
$query = "select * from PatientEventLog";
$search_result = filterTable($query);
}
function filterTable($query) {
$connect = mysqli_connect("localhost", "root", "GMd-eUJ-L6m-RxF", "lndappDB");
$filter_results = mysqli_query($connect, $query);
echo $filter_results;
return $filter_results;
}
?>
Why would this like statement not be picking up these NULL
values?