georgeocrawford
Technical User
Hi,
I am using a php script to write from a form to my MySql database.
Just a few things not quite perfect:
1.
The form has three seperate select fields for date input: day (1-31), month (Jan-Dec) and year (2002-2005).
I am using the following line to create a variable 'sqldate' which is posted to the database in the form YYYY-MM-DD:
$sqldate = "$year-$month-$day";
...but I need to change the month values so they are in the format '01-12' rather than 'Jan-Dec'. How can I do this?
2.
A similar problem.
My 'address' field is generated using the following line, and is a combination of 4 fields in the form separated by a comma:
$address = "$address1, $address2, $address3, $postcode";
This works perfectly when all 4 fields are filled-in, but when the user omits 'address2' and 'address3', for example, I get an entry like this:
"1 The Street, , , The Postcode"
How can I omit the space and the comma from '$address' when the field is left blank?
Thanks for your help!
I am using a php script to write from a form to my MySql database.
Just a few things not quite perfect:
1.
The form has three seperate select fields for date input: day (1-31), month (Jan-Dec) and year (2002-2005).
I am using the following line to create a variable 'sqldate' which is posted to the database in the form YYYY-MM-DD:
$sqldate = "$year-$month-$day";
...but I need to change the month values so they are in the format '01-12' rather than 'Jan-Dec'. How can I do this?
2.
A similar problem.
My 'address' field is generated using the following line, and is a combination of 4 fields in the form separated by a comma:
$address = "$address1, $address2, $address3, $postcode";
This works perfectly when all 4 fields are filled-in, but when the user omits 'address2' and 'address3', for example, I get an entry like this:
"1 The Street, , , The Postcode"
How can I omit the space and the comma from '$address' when the field is left blank?
Thanks for your help!