Hi all,
Another question! I'm currently using a date function to list all dates in the year in a select form from the current date, which converts them into numerical value for inserting into the db. This works fine - however, I wish to be able to use this function to also call the data from the db and edit the date field. So I assumed if I add an <b>option selected value=$my_date</b> to the top of the select form function, it would display the date already in the db at the top, proceeded by the dates of the year. However, it simply leaves that option blank (??) This is my function (taken from a tutorial):
function DateDropDown($size=365,$default="my_date") {
// $size = the number of days to display in the drop down
// $default = Todays date in m:d:Y format
// $skip = if set then the program will skip Sundays and Saturdays
$skip=0;
echo "<select name=my_date>\n";
echo "<option selected value='my_date'>$my_date</option>\n";
for ($i = 0; $i <= $size; $i++) {
$theday = mktime (0,0,0,date("m") ,date("d")+$i ,date("Y"));
$option=date("D M j, Y",$theday);
$value=date("Y:m:d",$theday);
$dow=date("D",$theday);
if ($dow=="Sun") {
echo "<option disabled> </option>\n";
}
if ($value == $default) {
$selected="SELECTED";
} else {
$selected="";
}
if (($dow!="Sun" and $dow!="Sat") or !$skip) {
echo "<option value=\"$value\" $selected>$option</option>\n";
}
}
echo "</select>\n";
}
Is there any reason why $my_date is not being echoed? I have checked and it is definitely being called from the db, and can be echoed as a text field, but not at the top of the select form.
Any ideas?