Can I update rows in sql based on a table generated in PHP?

I apologize if this question isn't asked well - first post on here. Very new with PHP and SQL in general.

I have a table displayed using a PHP foreach loop.

query:

SELECT * FROM ftu_inventory WHERE issuedto='$_GET[id]' ORDER BY item ASC

(using id 134 as example - partid is a unique primary key auto-assigned when the line is inserted)

partid item issuedto status
40 Beret 134 On Hand
16 Boots 134 On Hand
72 Jacket 134 On Hand
250 Jacket 134 On Hand
103 Pants 134 On Hand
240 Pants 134 On Hand

Answer

Solution:

If status will be updated to the same value, e.g. status = "On Hand", then you can do:

UPDATE ftu_inventory SET status = :newStatus WHERE id IN (...)

But if each item will update to it's own status, then you can group by new status, and then do fewer updates than just iterate through all:

   ...
   $statuses = array_column($items, null, 'status'); // Index by "status" array key

   foreach ($statuses as $status => $itemsBatch) {
       $this->update($status, array_column($itemsBatch, 'id'));
   }
   ...
}

public function update(string $status, array $ids): void
{
    $this->sql('UPDATE ftu_inventory SET status = :newStatus WHERE id IN :ids', [':newStatus' => $status, ':ids' => $ids]);
}

Code is pseudo-code and contains lots of missing actual code

Source