<?php
$days_2_search = array ( 1 => "Fri" , 2=>"Sun" , 3=>"Tue");
$num_days = 365;
$day = (int) date("d");
$month = (int) date("n");
$year = (int) date("Y");
echo "<form action=\"test.php\" method =\"post\">
<select name=\"days\">";
for ($i = 1 ; $i <= $num_days; $i++) {
$loop_day = date("D", mktime(0, 0, 0, $month, $day, $year) );
if ( in_array ("$loop_day" , $days_2_search) )
echo "<option name=\"day\"> " . date("D M j Y", mktime(0, 0, 0, $month, $day, $year)) . " </option>";
if (++$day > 31 || !checkdate($month,$day,$year) ) {
$day = 1;
if (++$month > 12 ) {
$month = 1;
++$year;
}
}
}
echo "</select><input type=\"submit\" value=\"go\"></form>";
?>
Rui Cunha
Daniel Clark writes:
A drop down with 365 days !?!? Isn't that a "little" big?
I have a problem, I currently have some code which populates a dropdown
box
- this code gives me every day for the next x amount of days (EG: a years
worth of days), however what I really need to be able to do, is to find a
way to display this data in the dropdown box but ONLY show 3 days a week,
IE: Mondays, Fridays and Sundays, so it would show the dates for each
Monday, Friday and Sunday for X amount of days (IE: 365 days in the
dropdown).
Does anyone have any idea how to do this? I would really appreciate any help, I'd send my sample code only I'm not at my home/work computer ATM.
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php