I'm trying to use the results of a MySQL select in a php script and make some updates in the same table.
For the following query, I need to look at each record and say "if order_status = 'S', set is_placement to 1 (this is a bit) and set date_updated to curdate()"
I can do that with an update, but the trick is I need to store the order_id of those with the status of 'S' in an array to use in another query.
I'm not sure how I would loop and store those in an array for that.
Here's the select:
$orderCheck = "
SELECT
order_id,
order_status
FROM order_status
";
EDIT (based on answers below): So I can make an array of order IDs like so:
$result = mysqli_query($connection,$orderCheck);
while ($row = mysqli_fetch_array($result))
{
$array = $row['order_id'}
if($row['order_status'] == 'S'){
Store ORder IDs here
}
}
But with that array and stored order IDs, I need to update the records for each ID.
How can I preform that update and store the necessary IDs as well?