View Full Version : [MySQL] [PHP] Inserting the values from 3 texboxes in 1 mysql column

03-10-2009, 02:51 AM
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:

$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.:thumbsup:

03-10-2009, 06:21 AM
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:

VALUES ("'".clean($sn)." ".clean($gn)." ".clean($gn)."'", "'".clean($other_stuff)."')")

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum