Topic: 2 Form Fields One DB Entry


szafranman    -- 01-05-2011 @ 10:03 PM
  I apologize in advance if this question has been posted
and answered multiple times. I am new to this site.

My question- I have made a form with First Name, Last
Name and many others I want to have both the First Name
and Last Name post into their respective columns in the
database but I would also like to combine the two and
have it entered into a column in the DB titled FULL NAME
with the format of Last Name, First Name. Is there a way
to do this?


szafranman    -- 01-05-2011 @ 10:06 PM
  By the way I have the everything working so far except I
would like to add the feature (I am asking about above)
of adding to the FULL NAME in the database.


megan    -- 01-06-2011 @ 8:12 AM
  before you do your insert query just set the fullname var and use that to insert the desired data into your db

e.g.

<cfset theFullName=form.FirstName & " " & form.LastName> or <cfset theFullName="#form.FirstName# #form.LastName#"> (they are the same thing)

hth ~megan

-------------------------------------------------------
"The chief cause of failure & unhappiness is trading what you want most for what you want now." ~Zig Ziglar


MarkSkid    -- 01-31-2013 @ 12:23 AM
  Yes above answer Is the best. Try hat way and you will get a solution.

Reliable SEO
Companies
for your
individual needs.


cfSearchin    -- 02-05-2013 @ 10:03 AM
 
quote:

I would also like to combine the two and
have it entered into a column in the DB titled FULL NAME


Any specific reason? Typically it is best to avoid storing calculated values because it is easy for them to get out of synch. Just concatenate the values in sql. The concatenation operator depends on your database, but in MS SQL something like
      
      

       SELECT  FirstName +' '+ LastName AS FullName
       FROM    TableName
       WHERE   ...
      



cfSearchin    -- 02-05-2013 @ 10:04 AM
  Oops, did not notice this post was years old. Darn spammers!


EasyCFM.COM ColdFusion Forums : http://archive.easycfm.com/forums
Topic: http://archive.easycfm.com/forums/viewmessages.cfm?Forum=35&Topic=15056