[PHP] Re: Simple calender

2004-05-31 Thread Torsten Roehr
Ryan A [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 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,
 mondayetc)
 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 wroteyour response would be appreciated. ;-)

Hi Ryan,

there is an excellent calendar package in PEAR with good documentation:
http://pear.php.net/package/Calendar

Here is a simple sample script to build a calendar that can easily be
modified:
http://pear.php.net/manual/en/package.datetime.calendar.intro-inahurry.php

Hope this helps.

regards, Torsten

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Simple calender

2004-05-31 Thread Craig
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:99;
color:ff;\;

 $calendar_html .= trtd colspan=\7\ align=\center\
style=\background-color:cc; color:00;\ .
   $month_name .   . $year . /td/tr;

   $calendar_html .= tr;
   $calendar_html .= tdS/td;
   $calendar_html .= tdM/td;
   $calendar_html .= tdT/td;
   $calendar_html .= tdW/td;
   $calendar_html .= tdT/td;
   $calendar_html .= tdF/td;
   $calendar_html .= tdS/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:cc;
color:00;\ /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 .= /trtr;

   $dispDate = $day_counter .   . $month_name .   . $year;

//Do something different for the current day.
if($day == $day_counter)
   $calendar_html .= td bgcolor=\#FF\
align=\center\ba href=\show.php?date= . urlencode($dispDate) .
isToday=1\ . $day_counter . /a/b/td;
else
   $calendar_html .= td align=\center\
style=\background-color:cc; color:00;\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 [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 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,
 mondayetc)
 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 wroteyour response would be appreciated. ;-)

 Thanks,
 -Ryan

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php