Results 1 to 3 of 3

Thread: [RESOLVED] retrieving data from a textarea

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2001
    Posts
    237

    Resolved [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

  2. #2
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    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')");


  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2001
    Posts
    237

    Re: retrieving data from a textarea

    thank you very much john tindell, it works! you're so cool!

Posting Permissions

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



Click Here to Expand Forum to Full Width