thanks rodders.
code in this file is:
if(isset($_POST['submitted4'])){
echo "<p>Please enter the date that you sowed the seeds";
//display calendar
$dates=getdate();
$sowmonth='sowmonth';
$sowday='sowday';
$sowyear='sowyear';
date_form($sowmonth, $sowday, $sowyear, $dates['mon'], $dates['mday'], $dates['year']);
echo '<input type="submit" name="submit" value="Enter date" />';
//echo '<input type="hidden" name="'. $hidden_submit .'" value="TRUE" />';
echo '<input type="hidden" name="submitted5" value="TRUE" />';
echo '</form>';
} // end of if $POST['submitted4']
if(isset($_POST['submitted5'])){
$test_result="$_POST[year]-$_POST[month]-$_POST[day]";
$query="INSERT INTO sowings (sow_date, sow_number, user_fk, number_sown, vegetable_fk, name_fk)
VALUES ('$test_result', '$sow_number', '{$_SESSION['user_id']}', '$number_sown', '$vegetable', '$veg_type')";
the date_form() function lives in a separate file. the code for the calendar is:
function date_form($month, $day, $year, $m=NULL, $d=NULL, $y=NULL) {
//create months dropdown
//create months array
$months=array(1=>'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
echo '<select name="' . $month . '">\n';
//being loop through array to create items for dropdown
foreach ($months as $key=>$value){
echo "<option value=\"$key\"";
if($key==$m){
echo ' selected="selected"';
}
echo ">$value</option>\n";
}
echo '</select>';
//begin day dropdown
echo '<select name="' . $day . '">\n';
for($day=1; $day<=31; $day++){
echo "<option value=\"$day\"";
if($day==$d){
echo ' selected="selected"';
}
echo ">$day</option>\n";
}
echo '</select>';
//begin year dropdown
echo '<select name="' . $year . '">\n';
for($year=2009; $year<=2020; $year++){
echo"<option value=\"$year\">$year</option>\n";
if($year==$y){
echo ' selected="selected"';
}
echo ">$year</option>\n";
}
echo '</select>';
I think it's something to do with the format of the date I'm trying to add to the db because the other values i enter in the sql statement
$query="INSERT INTO sowings (sow_date, sow_number, user_fk, number_sown, vegetable_fk, name_fk)
VALUES ('$test_result', '$sow_number', '{$_SESSION['user_id']}', '$number_sown', '$vegetable', '$veg_type')";
get entered fine.
All help much appreciated tho!