How can I prevent race conditions in PHP when multiple users update the same row in MySQL simultaneously? [closed]

I’m building an inventory management system using PHP and MySQL (InnoDB). When two users attempt to update the stock quantity at the same time, the latest write seems to overwrite the previous one, leading to inaccurate stock values.

I am expecting a quick and simple answer to complete my pending tasks.