PDA

Click to See Complete Forum and Search --> : [RESOLVED] retrieving data from a textarea


jimot
Mar 22nd, 2006, 04:22 AM
hi all.. I'm trying to insert data to a database using a textarea. What I want to do is to insert one record per line. So for example if in the textarea I have 10 lines, then it will save 10 items in the database. User must press Enter to go to next line in the textarea.
I have no problem if it's a text file, but how do you do that if it's a textarea?
thank you very much

john tindell
Mar 22nd, 2006, 06:08 AM
Just split the value up by \n and insert them into the database.


$lines = split("\n",$_REQUEST['textarea']);
foreach($lines as $line)
{
mysql_query("INSERT INTO your_table (Line) VALUES ('$line')");
}

jimot
Mar 22nd, 2006, 11:25 AM
thank you very much john tindell, it works! you're so cool!