For help, I want to implement the method of updating mysql database data using arrays. The data can be changed based on the array key value and value. For example, $ arr [13] Zhang San; $ arr [14] Li Si & nbsp; implements changes to id3 and id4 data in the database based on the key value and value of the $ arr array. The key value is age and the value is the name. Ask experts for help. ------ Solution ------------------ PHPc for help, using arrays to update mysql database data
I want to implement data changes based on the array's key value and value.
Example: $ arr [13] = 'Zhang San'; $ arr [14] = 'Li si'
Modify the data of id = 3 and id = 4 in the database based on the key value and value of the $ arr array. The key value is age and the value is the name.
Ask experts for help.
------ Solution --------------------
PHP code
// Append id, deformation: $ ar = array (3 => array (13 => 'Zhang San'), 4 => array (14 => 'Li si '),); foreach ($ ar as $ id = >$ v) {list ($ name, $ aeg) = each ($ v); $ SQL = "update tbl_name set aeg = $ aeg, name = '$ name' where id = $ id "; // perform database operations}