[prev in list] [next in list] [prev in thread] [next in thread]
List: php-general
Subject: [PHP] Re: Simple calender
From: 195.218.97.13
Date: 2004-05-31 10:18:55
Message-ID: 20040531102100.51078.qmail () pb1 ! pair ! com
[Download RAW message or body]
Ryan,
with a bit of tweaking you can edit that script to what you want.
heres an example
=================================================================
<?php
function calendar($date)
{
//If no parameter is passed use the current date.
if($date == null)
$date = getDate();
$day = $date["mday"];
$month = $date["mon"];
$month_name = $date["month"];
$year = $date["year"];
$this_month = getDate(mktime(0, 0, 0, $month, 1, $year));
$next_month = getDate(mktime(0, 0, 0, $month + 1, 1, $year));
//Find out when this month starts and ends.
$first_week_day = $this_month["wday"];
$days_in_this_month = floor(($next_month[0] - $this_month[0]) / (60
* 60 * 24));
$calendar_html = "<table style=\"background-color:666699;
color:ffffff;\">";
$calendar_html .= "<tr><td colspan=\"7\" align=\"center\"
style=\"background-color:9999cc; color:000000;\">" .
$month_name . " " . $year . "</td></tr>";
$calendar_html .= "<tr>";
$calendar_html .= "<td>S</td>";
$calendar_html .= "<td>M</td>";
$calendar_html .= "<td>T</td>";
$calendar_html .= "<td>W</td>";
$calendar_html .= "<td>T</td>";
$calendar_html .= "<td>F</td>";
$calendar_html .= "<td>S</td>";
$calendar_html .= "</tr>";
$calendar_html .= "<tr>";
//Fill the first week of the month with the appropriate number of
blanks.
for($week_day = 0; $week_day < $first_week_day; $week_day++)
{
$calendar_html .= "<td style=\"background-color:9999cc;
color:000000;\"> </td>";
}
$week_day = $first_week_day;
for($day_counter = 1; $day_counter <= $days_in_this_month;
$day_counter++)
{
$week_day %= 7;
if($week_day == 0)
$calendar_html .= "</tr><tr>";
$dispDate = $day_counter . " " . $month_name . " " . $year;
//Do something different for the current day.
if($day == $day_counter)
$calendar_html .= "<td bgcolor=\"#FFFFFF\"
align=\"center\"><b><a href=\"show.php?date=" . urlencode($dispDate) .
"&isToday=1\">" . $day_counter . "</a></b></td>";
else
$calendar_html .= "<td align=\"center\"
style=\"background-color:9999cc; color:000000;\"><a href=\"show.php?date=" .
urlencode($dispDate) . "&isToday=0\">" .
$day_counter . "</a></td>";
$week_day++;
}
$calendar_html .= "</tr>";
$calendar_html .= "</table>";
return($calendar_html);
}
echo calendar(NULL);
?>
=================================================================
"Ryan A" <ryan@coinpass.com> wrote in message
news:000301c446b2$eb584490$f081aa51@l2zcaxu7emppqh...
> Hey,
>
> been looking at a lot of calenders most of them are either too big for my
> use (whole page), not free, in javascript or too complicated.
>
> I require a calender that is simple, loads fast,small and not javascript,
> the closest I found is at:
> http://scripts.franciscocharrua.com/calendar.php
>
> just two problems with it,
> 1. It does not have the days on top (eg: s,m,t,w,t,f,s - sunday,
> monday....etc)
> 2. (not required but would be nice if it would) allow me to link from the
> days of the calender to some page/s
>
> I guess I could modify the above calender as it pretty good + open
> source...but if anybody is using a calender already which is like the
above
> + the 1 or two points I wrote....your response would be appreciated. ;-)
>
> Thanks,
> -Ryan
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic