The original post: /r/php by /u/Warm-Fan-3329 on 2024-12-12 23:27:10.
Hi,
Looking for some help with the below code. I am trying to have the below code update all rows when $startdate = today’s date. At this time, this functions but only updates 1 record at a time. What should I be doing to change this so that all records are updated at the same time?
while ($row = $stmt->fetch_assoc()) {
$startdate = "$row[startdate]";
$today = date('Y/m/d');
id = "$row[id]";
if ( ($startdate == $today) ) {
$sql = "UPDATE availability SET startdate='NEW_DATE' WHERE id=$id";
$result = $conn->query($sql);
if($result)
{
echo "Data updated successfully.";
}
else
{
echo "Error occurred while updating the record!";
echo "Reason: ", $conn->error;
}
$conn->close();
You must log in or register to comment.