Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jul 2006
    Posts
    168
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Saving Multiple Names in MySQL

    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.

    Ken

    Code:
    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";

  • #2
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,631
    Thanks
    4
    Thanked 147 Times in 138 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •