close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

combine or concatenate form fields

Thread began 3/11/2010 6:34 pm by evansg7124312885 | Last modified 1/11/2012 2:10 pm by afeliksas433126 | 4367 views | 12 replies |

evansg7124312885

combine or concatenate form fields

My site requires date calculations. I have set all pages that collect dates up to require users to select dates in 3 menu boxes; year, month, and day. So far I have built pages to express this data as needed using the 3 values separated by the text that makes it reader friendly. So far my work has been done in PHP/MySQL.

My databases are set up to receive year, month, day, and DATE (4 different fields); the user only enters 3 values and the 4th should be based on the prior 3. What I would like to do is at the insert or update pages, have the DATE field fill off of the 3 date values entered and insert the "-" at their appropriate points, or concatenate the values to make a valid DATE entry. Within the Insert/Update server behaviors and in the DATE field, here is a sample of one of several field command attempts that so far have failed to post vaild dates in the SQL database:
<?php echo ((isset($_POST["selYearcal1"]. "-" . $_POST["selMonthcal1"] . "-" . $_POST["selDaycal1"]))?$_POST["selYearcal1"]. "-" . $_POST["selMonthcal1"] . "-" . $_POST["selDaycal1"]:""); ?>

Again, I am trying to fill the DATE with a valid date value using the 3 user inputs.

I am learning (by no means skilled) PHP language, can anyone show me the syntax/command to combine form elements and text to create a valid date for database entry?

Thanks,

Gary

Sign in to reply to this post

evansg7124312885

follow on note

The form fields to collect the Year, Month, and Day are working fine, I am only trying to combine these 3 individual elements into 1 valid date value.

Sign in to reply to this post

Jimmy Wu

You will have to create a date object that is valid if your database column is date type:
date-and-time-functions.html#function_str-to-date

Sign in to reply to this post

afeliksas433126

How to concatenate two registration form fields into one

On the registration form I have 3 fields:
1. GrFirstName
2.GrLastName
3.GrFirstLastNameJoin

The same columns I have in PhpMyAmin database.

Question is - what is the way to concatenate "GrFirstName" and "GrLastName" in order to get "GrFirstLastNameJoin" without every single time typing them manually into registration form's field "GrFirstLastNameJoin"?

Sign in to reply to this post

Jason ByrnesWebAssist

there is no reason to have a separate GrFirstLastNameJoin column in the table.

on the page that outputs the user information, you can concatenate the First and last names by using the following code:

php:
<?php echo($row_recordsetName['GrFirstName']." ".$row_recordsetName['GrLastName']); ?>



where recordsetName is the name of the recordset that returns the user data from the database.

Sign in to reply to this post

afeliksas433126

To follow

What if I want "Name Surname" column from database to use in another form as a drop-down menu?

Sign in to reply to this post

Jason ByrnesWebAssist

use this same code as the value for the select list;

php:
<?php echo($row_recordsetName['GrFirstName']." ".$row_recordsetName['GrLastName']); ?>
Sign in to reply to this post

afeliksas433126

Can't get it work

Once again.

I'm inserting a new Registration Form.
Run "Record Insert Form Wizard".
Choose Table from Database list.
Select the form field (GrUserID) where I need to have menu, select Display as: Menu.
Menu Properties...
Do I need to select "Populate menu items" - manually or From database?
If from database - it prompts to choose Recordset (labels and values). Even if I paste In "Select value equal to:"
<?php echo ($row_WADADynListpcms2_users['UserFirstName']." ".$row_WADADynListpcms2_users['UserLastName']) ?> (as you suggested)

in menu on the form it gives just labels from Recordset.

Using Manual population it does not give any value.

What am I doing wrong?

Sign in to reply to this post

Jason ByrnesWebAssist

select to populate the menu from the database.

choose the first name column for both the label and the value

this will set the code for the options to look like:

php:
<option value="<?php echo($row_WADADynListpcms2_users['UserFirstName']); ?>"><?php echo($row_WADADynListpcms2_users['UserFirstName']); ?></option>





you will need to edit the code manually to:

php:
<option value="<?php echo($row_WADADynListpcms2_users['UserFirstName']." ".$row_WADADynListpcms2_users['UserLastName']); ?>"><?php echo($row_WADADynListpcms2_users['UserFirstName']." ".$row_WADADynListpcms2_users['UserLastName']); ?></option>
Sign in to reply to this post

afeliksas433126

Managed to get menu

Yes Jason, managed to get Name and Surname into my drop down menu.

But choosing from drop down menu "Name Surname" I want to post UserID value into database instead of "Name Surname".

What part of code I need to amend?

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...