so in my code, the user inputs a date and it is stored in a session variable. i need to compare the date in this variable to records in database and display the matching results. this is my code.
$date= $_SESSION["date"];
$result=mysqli_query($con,"select * from attendance where date = '$date'");
// this block below is for printing the records
if (!empty($result) && $result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "<br> - Name: ". $row["student_name"]. "- Status " . $row["attendance_1"] . "<br>";
}
} else {
echo "0 results";
}
when i execute this , it prints '0 results'. i tried echoing $date, and it has the date so its not the problem. i also checked the date format and made sure they are in the same format. when i type in the date directly (like '2021-03-23') instead of using the variable, i get results. i cant find answers anywhere, help would be much appreciated.