PHP / MySQL using check-boxes in a form to make multiple INSERT INTO for a MySQL database
Posted on 2012-04-12
I need to download all the members of parliament (stored in a MySQL database) into a HTML form using a PHP loop so that I can attach members names to legislation using check-boxes.
When the form is submitted, all the names with check-boxes selected shall have a row inserted in the table of the specific legislation.
- Legislation: Legislation_ID, name, date, attachment etc...
- Legislation_Support: Legislation_ID, Member_ID, Member_Name (INSERT_INTO)
- Parliament_Member: Member_ID, Member_Name (SELECT)
So the form needs to pull the data from Parliament_Member (some 400 parliamentarians), and present the parliamentarians with their Member_Name as check-boxes. Then upon submit Legislation_Support for the specified Legislation_ID, gets one row inserted for each check-box selected.