Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date

Status
Not open for further replies.

cherrielwy

IS-IT--Management
Jul 30, 2003
27
0
0
MY
Hi,

In my form, i make the date separate to 3 field(day,month&year) but i need to combine the date to 1 columb in my datbase,may i know how to do it?
 
add the values. in the php page where u collect the values:
$dd=$_POST['date_field'];//or whatever method u use
$mm=$_POST['month_field'];
$yy=$_POST['year_field'];

$date=$yy."/".$mm."/".$dd;
echo $date;

//now use $date in ur sql query...

Known is handfull, Unknown is worldfull
 
After assembling the date (like vbkris showed you) you might want to validate the result before sticking it into the database.

Here's a task for you to investigate:
What happens when you send 02/31/2003 to the database?
 
Hi,

I create three combo box for input, "day","month" and "year",the i put the code:
<?php
$dd=$_POST['day'];//or whatever method u use
$mm=$_POST['month'];
$yy=$_POST['year'];

$date=$yy.&quot;/&quot;.$mm.&quot;/&quot;.$dd;
echo $date;
?>

but the date cannot be show,whats wrong? How sticking it into my database?


thank.
Cherrie
 
Questions:
1. Is your form posting to the correct scipt?
2. What version of PHP are you using?
3. Try
Code:
<?php
print(&quot;<pre>&quot;);
print_r($_POST);
print_r($HTTP_POST_VARS); # older PHP versions
print(&quot;</pre>&quot;;
?>
 
Hi,DRJ478

i use php4,i'm just start learning php,can u help me. After i feild in the date, the value cannot be insert in to my database. How can i validate the result before sticking it into the database?Thank You
 
what do u mean by validate?
first did the date echo itself?

Known is handfull, Unknown is worldfull
 
the date had acho after i summit,but have not input to the database.How?Thank You



cherrie
 
to input it u need to perform an insert query. check on php's database connections...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top