Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Feb 2009
    Posts
    13
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Question [MySQL] [PHP] Inserting the values from 3 texboxes in 1 mysql column

    Ok, this is very simple question actualy.

    I have 3 textboxes: Sur_name, Middle_name and Last_name, but 1 cell called name in MySQL table. The question is how to insert those 3 values in 1 cell??
    Thanks in advance.

    Here is my current code sample from my script:

    PHP Code:

    $sn 
    $_POST['sur_name'.$i]; // Sur Name
    $gn $_POST['given_name'.$i]; // Given Name
    $mn $_POST['middle_name'.$i]; // Middle Name
    $other_stuff $_POST['other_stuff'.$i]; // Other Entries

     
    mysql_query("INSERT INTO a 
            (a.name, a.other_stuff)
            VALUES ('"
    .clean($sn)." ".clean($gn)." ".clean($gn)."', '".clean($other_stuff)."')")
            or die(
    mysql_error()); 
    Sure, I have other values but I've delete them only to show what I'm interested of.

    Thank you again for your help.
    "There are 2 kinds of people in the world: the kind that try to divide the world into 2 kinds of people, and the kind that dont."

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    My answer would be: you don't. You add two more columns to your table and store each name separately.

    But assuming you don't want to do that, I would handle the quotes a little differently:

    PHP Code:
    VALUES ("'".clean($sn)." ".clean($gn)." ".clean($gn)."'""'".clean($other_stuff)."')"


  •  

    Posting Permissions

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