I have a script written in PHP that has this line that works correctly to select the data I need;
$result = mysql_query("SELECT product_name, sku, qty FROM supplier_dropship_items WHERE supplier_id = '3' AND status = '2'", $db_beb);
What I'm struggling with is a way to update the records I have selected. After selecting, I need to change status = '1' so that the next time my script runs it, it will not pull out the same data in select and pull out only new items in the table that have status 2.
This is my working result thanks to the comments of the answer below;
$result = mysql_query("SELECT id, product_name, sku, qty FROM supplier_dropship_items WHERE supplier_id = '3' AND status = '2' FOR UPDATE", $db_beb); while($row = mysql_fetch_assoc($result)) { $sql_table_data[] = $row; mysql_query("UPDATE supplier_dropship_items SET status=1 WHERE id='".$row['id']."'", $db_beb); }
mysql select sql-update
TheWebsiteGuy
source share