Subscribe
$num_of_entries = 5;
for($i=0; $i < $num_of_entries; $i++) {br>
$form = '
<input name="phone[$i][type]">
<input name="phone[$i][number]">
<input name="phone[$i][extension]">
<input name="phone[$i][preferred]">
';
// Note: code doesn't work as-is... needs to be integrated
// within HTML of your form
}
echo $form;
>$_POST array. Specifically... the $_POST['phone'] part of the array (The post data is just one huge multi-dimensional array).foreach...
foreach ($_POST['phone'] as $key => $value) {
// You can do anything with the values here
// For instance, just display them to the user...
echo "Phone entry #".$key;
echo "Type: ".$value['type'];
echo "Number: ".$value['number'];
echo "Extension: ".$value['extension'];
echo "Preference: ".$value['preference'];
// Or you could enter them into a MySQL db
// Like so...
$sql = "INSERT INTO table_name VALUES (
'".$value['type']."',
'".$value['number']."',
'".$value['extension']."',
'".$value['preference']."'
);
$result = mysql_query($sql);
}
< ? br>
$array['foo'] = bar;
echo $array[0].'
';
echo $array['foo'];
?>
>
bar
bar
You are not logged in, either login or create an account to post comments
No sane OOP programmer would try this. Nor would functional programmers, they'd use structs.
Careful or you'll show up on the Daily WTF.
posted by jon_kill at 8:39 AM on November 23, 2005