Results 1 to 4 of 4

Thread: Inserting multiple rows

  1. #1
    Registered Mike's Avatar
    Join Date
    May 2003
    Location
    UK
    Posts
    2,755

    Inserting multiple rows

    Hi all,

    I want to get a textarea form and add each new line to a database as a seperate row. Does anyone know how to do this in PHP?

    I really haven't a clue where to start

    Thanks,
    Mike
    Don't you just love free internet games ?

  2. #2
    Roll Tide! mobilebadboy's Avatar
    Join Date
    Apr 2004
    Location
    Mobile, AL
    Posts
    428
    You can do that with the explode() function.


    PHP Code:
    $line explode ("\n"$foo); 
    Where $foo is the name of your textarea. $line would be an array, then you can handle the array however you want.


    PHP Code:
         foreach($line as $x) {
         echo 
    $x;

    That would echo out each line. Or you can do your insert from there.
    Last edited by mobilebadboy; 05-13-2004 at 03:37 PM.
    Shawn Kerr .com

  3. #3
    Future AstonMartin driver r2d2's Avatar
    Join Date
    Dec 2003
    Location
    UK
    Posts
    1,608
    You would get ur textarea text by:

    PHP Code:
        $textarea_text $_POST['textarea_name']; 
    Then as mobeilebadboy suggested, but could do:

    PHP Code:
    foreach($line as $x) {
         
    $sql="INSERT INTO table (text) VALUES ('$x')";
         
    $outcome mysql_query($sql);


  4. #4
    Registered Mike's Avatar
    Join Date
    May 2003
    Location
    UK
    Posts
    2,755
    I'll try it out later, thanks guys Thought it would be more complicated then that.
    Don't you just love free internet games ?

Similar Threads

  1. Google bot using multiple sessions.
    By Dan Morgan in forum Search Engine Optimization
    Replies: 3
    Last Post: 03-29-2004, 04:32 PM
  2. Randomly returning rows
    By Mike in forum Website Programming & Databases
    Replies: 8
    Last Post: 02-07-2004, 08:28 PM
  3. Excluding Rows in PHP?
    By Mike in forum Website Programming & Databases
    Replies: 18
    Last Post: 01-27-2004, 04:03 PM
  4. multiple websites ?
    By s2kinteg916 in forum General Management Issues
    Replies: 4
    Last Post: 11-23-2003, 09:46 PM
  5. multiple sites + amazon and cj.com ?
    By s2kinteg916 in forum Advertising & Affiliate Programs
    Replies: 5
    Last Post: 11-23-2003, 09:41 PM

Bookmarks

Posting Permissions

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