[RESOLVED] retrieving data from a textarea
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
Re: retrieving data from a textarea
Just split the value up by \n and insert them into the database.
PHP Code:
$lines = split("\n",$_REQUEST['textarea']);
foreach($lines as $line)
{
mysql_query("INSERT INTO your_table (Line) VALUES ('$line')");
}
Re: retrieving data from a textarea
thank you very much john tindell, it works! you're so cool!