Results 1 to 3 of 3

Thread: Split insert textarea value per line and insert each line as one record

Threaded View

  1. #1
    Join Date
    Sep 2013

    Split insert textarea value per line and insert each line as one record

    I need to know how to do the following using php coding please

    1.take inserted text from a textarea
    2.split the content per line
    3.Insert each line into the database as its own row with own id number
    Can anyone show me how to do this please?

    THis is what I have tried so Far:

    Below is my form page display_form.php:
    HTML Code:
    <form method="post" action="display_db.php">
    Member ID:
          <input name="mid" type="text" value=""><br/><br/>
    Enter Keywords:
          <input name="keywords" type="text" value=""><br/><br/>
          Enter Your Links :
    <textarea name="links" rows="3" cols="20"></textarea><br/><br/>
    <input type="submit" id="button" value=" Submit "/>
    And below is my display_db.php:
    PHP Code:
    // Check connection
    if (mysqli_connect_errno())
    "Failed to connect to MySQL: " mysqli_connect_error();
    $line_data explode("\n"$_POST["keywords"]);
    $line_data as $key => $value)
    $sql "INSERT INTO table (display) VALUE('{$value}')";
      if (!
    'Error: ' mysqli_error($con));
    "1 record added";

    Ant kind of help is appreciated.
    Last edited by NogDog; 12-14-2013 at 01:17 PM. Reason: added [php] tags
    strad solutionswww.stradsolutions.com

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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