Sorry, I've found out anything about this in other post but none can really solve my problem:
Imagine I'm writing an application to book travels. In the beginning I don't know the number of passengers so I ask it in a form.
Then I dinamically build a form to input data of each passenger, so if there are 4 pax I'll have a form with 4 text boxes asking passenger name. But each passenger can have different needs,maybe one need a single room, one need fullboard threatment,one need vegetarian food. Of course every hotel can offer different features for their guests needs and I dinamically load these features from a table.
So I have such a form :
<?
for($i=0;$i<$count_pax;$i++){
?>
Name <input name="name[]" type="text">
Age <input name="age[]" type="text"> <?
$query = "SELECT feature_id,feature_name
FROM hotels
WHERE hotel:id = '$hotel'
";
$result = mysql_query($query, $conn);
echo"<fieldset><legend>
Check feature/s you need :
</legend><table width=\"300\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
if (!$result) {
echo "Invalid SQL ".mysql_error();
}
$num = mysql_num_rows($result);
for($i=0;$i< $num;$i++){
$row = mysql_fetch_array($result);
?>
<tr>
<td width="250 ><? echo $row[1] ?></td>
<td width="50"><input name="feature" type="checkbox" value="<? echo $row[0] ?>"></td>
</tr>
<?
}
echo "</table></fieldset><br>";
}
But every checkbox need a different name, isn't it?
So how can I collect the $_POST in my next php page?
Ok for passengers name :
$count = count($name);
for($i=0;$i<$count;$i++){
echo $_POST['name'][$i]." ".$_POST['age'][$i]."<br>"
But what about the checkboxes?
}
Any help very appreciated.
Max