The date() function expects a unixtimestamp where you have $date_entered
I use the folowing function to create a drop down date box with the current date selected by default.
function s_day($cd="") {
for ($x=1; $x <= 31; $x++) {
$str = "<option value='" . sprintf("%02d", $x) . "'";
if ($x == $cd) { $str .= " selected"; }
$str .= ">" . sprintf("%02d", $x) . "</option>";
echo $str;
}
echo "</select>";
}
function s_month($cm="") {
$month_array = array("", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
for ($x=1; $x <= 12; $x++) {
$str = "<option value='" . sprintf("%02d", $x) . "'";
if ($x == $cm) { $str .= " selected"; }
$str .= ">" . $month_array[$x] . "</option>";
echo $str;
}
echo "</select>";
}
function s_yearu($length="",$cy="") {
$cYr = date("Y");
for ($x = $cYr; $x < ($cYr + $length); $x++) {
$str = "<option value='" . $x . "'";
if ($x == $cy) { $str .= " selected"; }
$str .= ">" . "$x" . "</option>";
echo $str;
}
echo "</select>";
}
Then in the the html code would be comething like:
<select name='day'><? echo s_day(date("d")); ?>
<select name='mth'><? echo s_month(date("m")); ?>
<select name='yr'><? echo s_yearu(3,date("Y")); ?>
then php code to accept the selected date:
$datestamp = "$yr-$mth-$day";
which will store datestamp like 2004-10-08 which works best for MySQL