Jump to content

insert 2 form fields into 1 mysql column


kaiman

Recommended Posts

I have two fields from a form called $firstname and $lastname and want to insert them into a single column called 'name'

 

Can someone give me a quick rundown on how to array them so that the two name fields can be joined together with a space in between them and then inserted into the 'name' column in the database?

 

Thanks in advance,

 

kaiman

I have two fields from a form called $firstname and $lastname and want to insert them into a single column called 'name'

 

Can someone give me a quick rundown on how to array them so that the two name fields can be joined together with a space in between them and then inserted into the 'name' column in the database?

 

Thanks in advance,

 

kaiman

 

$fullName = $firstName . " " . $lastName;

Nightslyr - thanks for the reply. I have a couple more questions:

 

I was reading elsewhere about needing to use the "implode" and "explode" functions to do this. Is this no longer necessary?

 

Can I just take:

 

$firstname = cleanString($_POST['firstname']);

$lastname = cleanString($_POST['lastname']);

 

and then array them simly like this:

 

$name = $firstname . " " . $lastname;

 

and then insert them with the other form data like this:

 

$sql="INSERT INTO $tbl_name1(name)VALUES('$name')";

$result=mysql_query($sql);

 

Or is there something I'm missing?

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.