Well, I can't really do it that way for other reasons. I did try renaming my Name input field to Name[] and then using:
foreach($_POST['Name'] as $i=>$v) {
$strVals[] = "('".$v."','".implode(',', $_POST['Age'.$i])."')";
$strSql .= implode(",", $strVals);
}
print_r($_POST);
echo "<p>".$strSql;
Which almost worked, except that I get duplicates. So, if the array is:
Array (
[Name0] => Doe
[Age0] => Array ( [0] => 23 [1] => 28 [2] => 32 [3] => 11 [4] => 9)
[Name1] => Smith
[Age1] => Array ( [0] => 7 [1] => 8 [2] => 9 )
[Name2] => Jones
[Age2] => Array ( [0] => 54 [1] => 42 )
[submit] => Submit
)
I'll get:
('Doe','23,28,32,11,9')('Doe','23,28,32,11,9'),('Smith','7,8,9')('Doe','23,28,32,11,9'),('Smith','7,8,9'),('Jones','12,13,14')
When I echo $strSql. What I want is this:
('Doe','23,28,32,11,9'),('Smith','7,8,9'),('Jones','12,13,14')