我有多个复选框,在我的我的网页之一腓 - 获取多个复选框,输入
<form method="POST" action="flight_cart.php" autocomplete="off">
<table>
<?php
for($i = 1; $i <= 5 ; $i++)
{
print "<tr>
<td><input class='seats' name='seats[$i]' type='checkbox' value=S".$i.">Seat " .$i. "</input></td>
<td><input class='special s$i' name='special[]' type='checkbox' value='noNuts'>No Nuts</input></td>
<td><input class='special s$i' name='special[]' type='checkbox' value='noGluten'>No Gluten</input></td>
<td><input class='special s$i' name='special[]' type='checkbox' value='noCorn'>No corn</input></td>
</tr>";
}
print "<tr><td><button type='submit' onclick='return submitValidation();'>Add to Bookings</td></tr>";
?>
</table>
我想使用PHP,例如获得在接下来的页面中的数据:
座椅S1; NoNuts,NoGluten
座椅S2; NoNuts,NoCorn
到目前为止,我只能够得到回升席位
<?php
$booked_seats = $_POST['seats'];
$special = array();
for($i = 0; $i < sizeof($booked_seats); $i++)
{
for($j = 0; $j < sizeof($_POST['special']); $j++)
{
$currentValue = $_POST['special'][$j];
$special[$i][$j] = $currentValue;
}
}
阵列我想用来存储所有的数据到二维数组。所以..
特殊[1] [0]是noNuts
特殊[1] [1]是noGluten
特殊[2] [0]是noNuts
特殊[2] [1]是noCorn
请帮帮我。先谢谢你!
什么结果你现在得到些什么? –
你似乎是沉默的类型,你给出的答案的接受记录似乎也反映了这一点。你来这里寻求帮助,给出了评论,要求澄清和答案,因为这也是不被接受的。如果你想保持良好的排名,你需要合作。这是一条双向的街道,而不是一条街道。 –
目前我只能将所有特殊[]值填充到一个数组中。我不知道如何将它填充到2D数组中 –