我有这个需要插入数据库的数组。我下面的代码不起作用,我最终得到相同的值。
array(10) { [0]=> array(1) { ["GymnastName"] => string(7) "ertwert" }
[1]=> array(1) { ["GymnastName"] => string(6) "wergfb" }
[2]=> array(1) { ["GymnastAge"] => string(8) "ewrtwert" }
[3]=> array(1) { ["GymnastAge"] => string(8) "dsfvsdtg" }
[4]=> array(1) { ["ParentsName"] => string(9) "werfgdsfv" }
[5]=> array(1) { ["ParentsName"] => string(9) "wetrgwerg" }
[6]=> array(1) { ["ParentsEmail"] => string(7) "erteqrt" }
[7]=> array(1) { ["ParentsEmail"] => string(6) "adfwer" }
[8]=> array(1) { ["ParentsPhone"] => string(7) "ertwert" }
[9]=> array(1) { ["ParentsPhone"]=> string(4) "qert" }
}
这是我的循环:
for ($i=0; $i<$l; $i++) {
$name = $gymarray[$i];
$age = $gymarray[$i];
$parentname = $gymarray[$i];
$parentemail = $gymarray[$i];
$parentphone = $gymarray[$i];
$db->insert statement here
本质上,我需要将记录插入为 GymnastName、GymnastAge、ParentsName、ParentsEmail、ParentsPhone。
我最终得到的最终代码是:
array(1) {
["GymnastName"]=>
string(7) "ertwert"
}
array(1) {
["GymnastName"]=>
string(7) "ertwert"
}
array(1) {
["GymnastName"]=>
string(7) "ertwert"
}
array(1) {
["GymnastName"]=>
string(7) "ertwert"
}
array(1) {
["GymnastName"]=>
string(7) "ertwert"
}