我有一个$ _POST数组的提交按钮,隐藏,cbo和文本,当我在发布后循环遍历该数组时,无论设置什么,它只会返回数组的最后一个。
已经尝试过isset,然后遍历数组
$i=0;
while($row = mysql_fetch_array($result)){
$body .= "$<input type='text' name='txtOTHER_INCOME_AMT' value='" .
$row['INCOME_AMT'] . "'>
<input type='submit' name='cmdUpdateIncome' value='Update'>
<input type='hidden' name='income_id' value='" . $row['INCOME_ID'] . "'>";
$i++;
}
//check and see if the user is trying to update an OTHER INCOME
if ($_POST['cmdUpdateIncome'] != "" && $_POST['updateincome_id'] != "") {
for ($i=0; $i>count($_POST['cmdUpdateIncome']); $i++){
if (isset($_POST['cmdUpdateIncome'])){
//do some stuff
}
}
}
如果用户单击n个按钮中的第三个,我想从与所选按钮相关的表单中获取这些字段的值:
txtOTHER_INCOME_AMT和income_id(数据库中的密钥,以便我可以根据txtOTHER_INCOME_AMT中提供的内容进行更新)。
print_r($_POST)
给予
[cboOTHER_INCOME_TYPE_CODE] => Array (
[0] => F4
[1] => F1
[2] => M3
[3] => F2
[4] => F9
[5] => 41
[6] => F7
[7] => TL
)
[txtOTHER_INCOME_AMT] => Array (
[0] => 1007.07
[1] => .01
[2] => 1326.02
[3] => 502.36
[4] => 10001.03
[5] => 150.77
[6] => 100.22
[7] => 500.44
)
[cmdUpdateIncome] => Array (
[0] => Update
)
[income_id] => Array (
[0] => 1
[1] => 6
[2] => 7
[3] => 8
[4] => 9
[5] => 10
[6] => 11
[7] => 13
)