Updating SQL database date within PHP

Asked by At

Using a mysqli_multi_query to allow the user to update elements of an order (Quantity of items and chosen delivery date), the quantity query updates no problem on its own. But the delivery date part is not executing at all. The multi query does involve executing two queries on two different tables (Order & Order information), but wouldn't have thought this would be the issue.

I've tried executing the query as a standard mysqli_query (not multi) to see if it was an issue there, but the result is the same in that it is printing out the query on the page (UPDATE mytable.Order SET Chosen_Delivery_Date = '' WHERE Order_ID = '1')

From what I can see in the above (), it looks like its not reading the changed delivery date? I've tried moving the syntax around in case it was a mistake there but had no luck.

The code I've provided is the standard (not multi) query I've been working with, as would just like to get the initial query working first before i step back into making things more complicated with multi.

The code executes through 2 pages, first the page that takes the new delivery date input:

echo "<td><input type=date name='Chosen_Delivery_Date' value='".$row['Chosen_Delivery_Date']."'></td>";
echo "<td><input hidden = date name = Chosen_Delivery_Date = '".$row['Chosen_Delivery_Date']."'></td>";

Second the page that executes the query based on this input:

// This assigns the new delivery date to a variable
$Delivery = $_POST['Chosen_Delivery_Date'];

//executing the query 
 $update = "UPDATE Order SET Chosen_Delivery_Date='$Delivery' WHERE Order_ID = '$Order_ID'";
if(mysqli_query($conn,$update)) {
    echo "Order updates sucessfully";
}
else {
    echo "Error updating order: ".mysqli_error($conn);
}

All connections with the database are working no problem, but do let me know if any of you would like to see these connections or how the table is being read/echoed for the user to read before they change the the values.

0 Answers