Greetings,
I am having such trouble with inserting multiple records from an array and 2 other fields.
My form consist of this:
<input type="hidden" name="id" value="" />
<input type="hidden" name="pid" value="587" />
<select name="staff[]" id="staff" multiple="" size="5">
<option value="456">Last Name, First Name</option>
<option value="457">Last Name, First Name</option>
<option value="458">Last Name, First Name</option>
</select>
My DB table is structured like this
id | uid | pid
When someone submits this form I would like to insert the values of the form into the above table so that a record is created for each "staff[]" value:
id | uid | pid
1 456 587
2 457 587
3 458 587
I have tried everything from foreach to implode to ...... and I have yet to get this to work. I also understand that in order to get multiple records into the DB on an insert the format has to be as follows:
INSERT INTO table_name (col1, col2, col3) VALUES (val1, val2, val3), (val1, val2, val3) etc.
I just can't seem to parse the array from "staff[]" correctly. Can someone please help me with the PHP code for this?