The code below only returns one result. The remaining five results are blank. How can I return all rows?
foreach($dates as $date){
if($stmt->prepare("SELECT event FROM calendar WHERE date = ?")) {
$stmt->bind_param('i',$date);
$stmt->execute();
$stmt->bind_result($event);
$stmt->store_result();
while($stmt->fetch()) {
echo $event;
}
$stmt->close();
}
}
You closed the prepared statement in the first execution of foreach loop.
Move your $stmt->prepare("SELECT event FROM calendar WHERE date = ?")
outside of the foreach loop and
$stmt->close()
outside of foreach loop
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With