Jump to content

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?

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.