# Here is a datepicker that I wrote in PHP. Comments welcome !
# It's supposed to give you an endless calender and a link with the
# resulting timestamp when a day is clicked. I might add a time-field
# later. I know the code is not perfect, since I am not :-) If you have
# suggestions, please post them here. I have been searching for other,
# ready-made stuff, but could not find any. So I wrote this myself, since
# I did not want to use any Java etc, only HTML.
# Copy and paste this to a file, name it "datepicker.inc.php" and run it.
# It works as far as I could
\n";
$nextmonth_ts=strtotime("+1 month", $month_ts);
$lastmonth_ts=strtotime("-1 month", $month_ts);
$nextyear_ts=strtotime("+1 year", $month_ts);
$lastyear_ts=strtotime("-1 year", $month_ts);
$output="$output\n \n ";
$output="$output\n<";
$output="$output $thatmonth >\n";
$output="$output <";
$output="$output $thatyear >";
$output="$output \n\n\n";
$output="$output\n";
for ($x=$firstwday;$x<=($firstwday+6);$x++)
{$output = "$output$weekarray[$x]\n";}
$output="$output\n\n";
$firstweek=true;
for($x=0;$x<$numberofdays;$x++)
# iterate through all days of the month
{
$day_ts=strtotime("+$x day",$firstofmonth_ts);
$weekday=date("w", $day_ts);
$day=date("j", $day_ts);
if ($firstweek==true) {$firstweekgap=$t;}
if ($weekday==$firstwday)
#first day of the week new line start
{
if ($firstweek==true) {$output2 = "$output2\n\n";}
$firstweek=false;
$t=0; # set first day of week
$output2 = "$output2\n";
}
$t++;
$output2="$output2 $day\n";
if ($t==7)
#last day of the week display
{$output2="$output2\n\n";}
}
$gap=7-$firstweekgap;
if (($gap>0) AND ($gap<7))
{$output="$output\n\n$output2";}
else
{$output="$output$output2";}
$output="$output\n";
echo $output;
}
?>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php