This question has already been answered:

How to update multiple records in the database?

There is such an array $ update_user in it like this:

Array ( [makaka_kaka] => Array ( [0] => 37.00 ) [makdak04] => Array ( [0] => 37.00 ) [simba03] => Array ( [0] => 37.00 ) [peter02] => Array ( [0] => 37.00 ) [tester] => Array ( [0] => 37.00 ) ) 

And there is such a table with the name users

 ________________________________ | id | record | user | |----|-------------|------------| | 1 | 00.00 | makaka_kaka| |----|-------------|------------| | 2 | 00.00 | user4 | |----|-------------|------------| | 3 | 00.00 | makdak04 | |----|-------------|------------| | 4 | 00.00 | oser0007 | |----|-------------|------------| | 5 | 00.00 | peter02 | |----|-------------|------------| | 6 | 00.00 | 7788 | |----|-------------|------------| | 7 | 00.00 | 8867 | |----|-------------|------------| 

How to make an update request to update the record field where the user matches the login from the array.

In the record field you need to insert what is in the array of the user.

Reported as a duplicate by members of Mike , Cheg , ߊߚߤߘ , br3t , αλεχολυτ 19 Oct '17 at 10:17 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

    1 answer 1

     foreach ($update_user as $user_name) { foreach ($user_name as $key => $value) { $upd = 'UPDATE `users` SET `record` = '.$value.' WHERE `user`='.$key; mysql_query($upd); } }` 
    • And such a request does not polizhit server? On the day about 40 such requests will be. - Tokwiro
    • When you process an array it lays down the server? - No, in this case, too, will not. For the test, look at the load on the database on the hosting and see that nothing has changed ... - Web Desg
    • Well, the site is still in development, just worried so that later on the move they do not suffer. But as they say in practice, I recognize everything. Thank you for your help. - Tokwiro
    • Don't worry, everything will be fine ... - Web Desg