Web Hosting Talk







View Full Version : Inserting multiple lines in PHP into MySQL


golfer
06-22-2003, 01:40 AM
Anyone know how to do the following in PHP?....

In a text message form I want to submit each word on each line to a column on one of my MySQL tables...

For example, if a user submits the following data in a form:

word1
word2
word3
word4
word5
------------------------

I want each word to be submitted into a MySQL table called "Table_Words", and into a column named "Words"..... So "word1", "word2".. etc. will each be on its own separate row.

digitok
06-22-2003, 02:09 AM
You could explode it by \n like

$words = explode("\n",$text);

Then run a loop to insert each part of the array into the table.