Re: INSERT Question
| From: | Charles Kline | Date: | Sat, 29 Mar 2003 22:30:01 +0000 |
| Subject: | Re: INSERT Question | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-26704@lists.php.net to get a copy of this message | ||
Since I don't totally understand (newbie) I will show you an example of the form.
<form>
<select name="person1">
<option value="1">Joe Smith</option>
etc.
</select>
<input type="radio" name="person1yn" value="Yes"> Y <input type="radio" name="person1yn" value="No"> N
<select name="person2">
<option value="1">Joe Smith</option>
etc.
</select>
<input type="radio" name="person2yn" value="Yes"> Y <input type="radio" name="person2yn" value="No"> N
and so on...
<input type="submit">
</form>
On Saturday, March 29, 2003, at 05:25 PM, John W. Holmes wrote:
I was wondering what is the best way to insert multiple records into a table? Here is the scenario... I have a form which has 5 select menus as part of the data that gets entered. Most of the data goes into a table called tbl_reports. Eachofthese 5 menus contains the same list of people (from tbl_people). I have another table which I am calling tbl_report_people which I wanttoINSERT a record for each person that is selected for any new report (I hope this is making sense). So for example, a new report form isfilledout and submitted. 3 of the people selects are used, so I need to add to the tbl_report_people table the record_id and person_id for each person selected.The fastest way will be to create your INSERT dynamically and do them all at once. The format would be: INSERT INTO table (column1, column2) VALUES (value1,value2),(value11,value22),(value111,value222) If you're getting record_id and person_id from a form, you can just loop through them and create each (value,value) part and then add on the beginning. Without seeing your actual form, that'd be about the best advice I can give. ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/