for ($i = 0; $i < count($name); $i++)
{
//some output ommited
First you have to concat $i
to name
to get unique names:
for ($i = 0; $i < count($name); $i++)
{
echo "<td><input type='submit' value='Purchase' name='$name . $i'></td></tr>";
}
If $name
is "name" then you will get "name1", "name2", "name3", etc.
Then you can print_r($_REQUEST)
; to see the items submitted.
You do not need a for loop to see which of the items is set, but if you want to loop through the REQUEST array you could do something like this:
foreach($_REQUEST as $post_var)
{
if('name' == substr($post_var, 0, 4))
{
echo $post_var . ' ';
}
}
Result:
name1 name2 name3