EasyCFM.COM ColdFusion Forums / Dreamweaver / 2 Form Fields One DB Entry

   Reply to Discussion | New Discussion next >> 
Posted By Discussion Topic: 2 Form Fields One DB Entry

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

szafranman
01-05-2011 @ 10:03 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 2
Joined: Jan 2011

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
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 2
Joined: Jan 2011

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
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 2398
Joined: Jan 2003

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
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Member
Posts:
Joined: Nov 2012

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
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 608
Joined: Feb 2008

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
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 608
Joined: Feb 2008

Oops, did not notice this post was years old. Darn spammers!


Website Designed and Developed by Pablo Varando.