View Full Version : Saving Multiple Names in MySQL

08-27-2006, 10:10 AM
I have a form with a drop down box where you can select however many names out of the list that you would want the form information sent to. This is a business form and would have a maximum of 10 - 15 names selected.

I am not sure how I would get this form field into the database in a format that would allow me to select that column to send emails. I am thinking that it will have to be in a csv file format.

Since I have a query that inserts all of the other fields into the DB, I am thinking I will have to create a separate query to make this a csv file format and insert it into the DB.... I am not really sure how to do this, and am looking for help with this..... I am not sure if I can create a second query or if it will cause an error in the first query because the number of columns won't match to the number in the query....so maybe the two queries have to be joined.

In the end, I need to be able to call these names, and select the corresponding email addresses from another table so the results of the original form can be sent to them.I have put the name and value in bold to make it easier to see how I guessed it might work....Any help would be appreciated.


mysql_query ("Insert into `workorder`(ID,Work, Sched, Name, (Send(,,,)), Site, Serial, Hours,
Starts, Issue, Severity, Resolution, Assistance, NumberA, PartsA, NumberB,
PartsB, NumberC, PartsC, NumberD, PartsD, NumberE, PartsE, NumberF, PartsF,
NumberG, PartsG, Safety, Upload1, Upload2, Upload3, Upload4) VALUES
('', '$Work', '$Sched', '$Name', ($Send(,,,)), '$Site', '$Serial', '$Hours', '$Starts',
'$Issue', '$Severity', '$Resolution', '$Assistance', '$NumberA', '$PartsA',
'$NumberB', '$PartsB', '$NumberC', '$PartsC', '$NumberD', '$PartsD',
'$NumberE', '$PartsE', '$NumberF', '$PartsF', '$NumberG', '$PartsG',
'$Safety', '$Uploads1', '$Uploads2', '$Uploads3', '$Uploads4')")
or die(mysql_error());
echo "Work Order # '$Work' has been Updated Successfully";

08-27-2006, 02:40 PM
you would have a single column for the names. you should use EXPLODE in PHP to split them up.

You should also take the time to read on DATABASE NORMALIZATION as your table most definitely is not normalized. I've included a link in the resources thread at the top of the forum.