我想循环通过父母并为每个$ _POST [' start_time_uuid']获取孩子,我似乎无法为每个家长找到合适的孩子。
$max = sizeof($_POST['start_time_uuid']);
for ($x=0;$x<$max;$x++){
$soa = sizeof($_POST['start_time']);
for ($i=0; $i < $soa;$i++){
$start_time = $_POST['start_time'][$i];
$end_time = $_POST['end_time'][$i];
$fieldsVals = array(
'start_time' => $start_time,
'end_time' => $end_time
);
}
$where = array('uuid' => $_POST['start_time_uuid'][$x]);
$disregard = $PDO->sql_update($fieldsVals, $table, $where);
}
答案 0 :(得分:1)
试试这个
$max = sizeof($_POST['start_time_uuid']);
for ($x=0;$x<$max;$x++){
$soa = sizeof($_POST['start_time']);
for ($i=0; $i < $soa;$i++){
$start_time = $_POST['start_time'][$i];
$end_time = $_POST['end_time'][$i];
$fieldsVals[$x]['start_time'] = $start_time;
$fieldsVals[$x]['end_time'] = $end_time;
}
$where = array('uuid' => $_POST['start_time_uuid'][$x]);
$disregard = $PDO->sql_update($fieldsVals, $table, $where);
}
使用您的代码:
$fieldsVals = array(
'start_time' => $start_time,
'end_time' => $end_time
);
您似乎只使用另一个2元素数组覆盖前一个数组。 如果将其设为多维数组,则可以保存所需的数据。 希望这是你的意思,这有助于