kaiman Posted October 21, 2009 Share Posted October 21, 2009 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 Link to comment https://forums.phpfreaks.com/topic/178493-insert-2-form-fields-into-1-mysql-column/ Share on other sites More sharing options...
KevinM1 Posted October 21, 2009 Share Posted October 21, 2009 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; Link to comment https://forums.phpfreaks.com/topic/178493-insert-2-form-fields-into-1-mysql-column/#findComment-941278 Share on other sites More sharing options...
kaiman Posted October 21, 2009 Author Share Posted October 21, 2009 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? Link to comment https://forums.phpfreaks.com/topic/178493-insert-2-form-fields-into-1-mysql-column/#findComment-941291 Share on other sites More sharing options...
kaiman Posted October 21, 2009 Author Share Posted October 21, 2009 bump Link to comment https://forums.phpfreaks.com/topic/178493-insert-2-form-fields-into-1-mysql-column/#findComment-941592 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.