SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast cwb's Avatar
    Join Date
    May 2004
    Location
    Michigan
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Adding Multiple Lines In DB With Textarea

    I am trying to use a textarea to add a row in a db table for each line. My code below is working but it is appending a "%0D" (without the quotes) at the end of each item. Anyone know how I can get rid of that? Thanks!

    PHP Code:
    <?
    include("dbconnect.inc");
    $data explode("\n"$_POST['item']);
    $rows count($data);
    foreach(
    $data AS $key=>$value){
    mysql_query("INSERT into items_list (item) VALUES ('$value')");
    }
    ?>

  2. #2
    SitePoint Guru
    Join Date
    Dec 2005
    Posts
    982
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think it's a hard return \r

    Try
    PHP Code:
    <?
    include("dbconnect.inc");
    $data explode("\r\n"$_POST['item']);
    $rows count($data);
    foreach(
    $data AS $key=>$value){
    mysql_query("INSERT into items_list (item) VALUES ('$value')");
    }
    ?>
    MySQL v5.1.58
    PHP v5.3.6

  3. #3
    SitePoint Enthusiast cwb's Avatar
    Join Date
    May 2004
    Location
    Michigan
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, that was it.
    Thanks!


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
  •