Submit Values From Multiple Textboxes As Arrays
Basically what I want my program to do is to ask the user how many numbers they want to enter. Once the value is submitted, the program will take the value and create this amount o
Solution 1:
Just use PHP's array notation for form field names:
<inputtype="text" name="textbox[]" />
^^---force array mode
which will produce an array in $_POST['textbox']
, one element for each textbox which was submitted with the textbox[]
name.
e.g:
<inputtype="text" name="textbox[]" value="1" />
<inputtype="text" name="textbox[]" value="foo" />
<inputtype="text" name="textbox[]" value="banana" />
produces
$_POST = array(
'textbox' => array )
0 => 1,
1 => 'foo',
2 = > 'banana'
)
)
Your problem is that you're using single-quoted strings ('
), meaning that
$var = 'foo';
echo'$var'// outputs $, v, a, recho"$var"// outputs f, o ,o
Post a Comment for "Submit Values From Multiple Textboxes As Arrays"