Dates in "To Do" List

I have made myself a “To Do” list which I add refinements to every once in a while. I have the following code for selecting the date for which I want the task to be active. Most tasks that I add are for the current date, but sometimes I want to included something to show up in the future.

So what I would like to do (and can’t figure out how) is to have the current date showing on the drop-down menu by default, until I change it if needed. :confused:

I’d be quite happy with just some hints as to what my strategy should be so that I can try to figure out the code. Thanks.

<select name="month">
						<?php	$month_name = array(January, February, March, April, May, June, July, August, September, October, November, December);
						for ($i=0; $i<12; $i++) {
							$month_number = $i + 1;
							if ($month == $month_number) {
								$selected = "selected=\\"selected\\"";
							} else {	
								$selected = "";
							}
							print ("<option value=\\"$month_number\\" $selected>$month_name[$i]</option>");
						}
						?>
						</select>
						<select name="day">
							<?php
								for ($i=1; $i<=31; $i++) {
									if ($day == $i) {
										$selected = "selected=\\"selected\\"";
									} else {
										$selected = "";
									}
									print("<option value=\\"$i\\" $selected>$i</option>");
								}
							?>
						</select>
						<select name="year">
							<option value="<?php print $current_year; ?>"
								<?php
									if ($year == "$current_year") {
										print(" selected=\\"selected\\" >");
									} else {
										print(">");
									}
								?>
							<?php print $current_year; ?></option>
							<option value="<?php print $next_year; ?>"
								<?php
									if ($year == "$next_year") {
										print(" selected=\\"selected\\">");
									} else {
										print(">");
									}
								?>
							<?php print $next_year; ?></option>
						</select><br />
						

Hint:

echo date('j'); // prints day 1 to 31
echo date('n'); //prints month 1 to 12
echo date('Y'); //prints year 2012


for ($i=1; $i<=31; $i++) {
 if ($i == date('j') {
  $selected = "selected=\\"selected\\""; 
 } else { 
  $selected = ""; 
 } 
 print("<option value=\\"$i\\" $selected>$i</option>"); 
} 

Okay, so that shows the current date. I could have done that, but I was confusing it with also wanting to change to a different date for the occasional task. Now your hint made me realize that when I change the date, I really don’t want it to retain that one but to go back to the current date as the default. doh!! Thanks for clearing that up. :slight_smile:

So what I would like to do (and can’t figure out how) is to have the current date showing on the drop-down menu by default

Okay, so that shows the current date. I could have done that …

:rolleyes: :wink: