I have a similar form as here.
It has a dynamic number of inputs, e.g.
<li><input type="text" name="friend_1" id="friend_1" /></li>
<li><input type="text" name="friend_2" id="friend_2" /></li>
<li><input type="text" name="friend_3" id="friend_3" /></li>
<li><input type="text" name="friend_4" id="friend_4" /></li>
<li><input type="text" name="friend_5" id="friend_5" /></li>
</ol>
<input type="button" value="Add Friend Field" onclick="addField('friends_area','friend_',10);" />
Usually, when you want to process a form, you will refer
to certain form variable as $_POST['friend']
.
- Is there a way to collect all
$_POST['friend_X']
into an array? (note that there may be gaps) - and insert it into an
MySQL table
? Is it possible with one insert statement (I'm using PDO) or should I do it with for loop?