I have an array containing about a 50 items. Each item is an ID => price, and I have a table called products, I need to update the price of the product to the new price in the array which is referenced using the id
I could use a foreach loop and do the following
foreach($products as $ID => $price) {
$result = mysqli_query($link, "UPDATE product SET price = $price WHERE id = $ID");
}
But that will ultimately end up in me running almost 50 queries, is there a faster way to do it or a better practice?