Calendar class on the same page , suitable for reservation
me = $num ; 
$this->beg = $beg ; 
$this->end = $end ; 
} 
function jj ( $goto , $c1 , $c2 ) 
{ 
global $beg , $end ; 
$lastday = array(0,31,28,31,30,31,30,31,31,30,31,30,31); 
if ( $this->me == 1 ) { $t = $c1 ; } 
else { $t = $c2 ; } 
$today = getdate( $t ); 
$tbuff = mktime(0,0,0,$today['mon'],1,$today["year"] ) ; 
$tDate = getdate( $tbuff ); 
$firstwday= $tDate["wday"]; 
$ld = $lastday[$tDate['mon']]; 
$td = $today["mday"]; 
if ( ( $tDate["year"] % 4 ) == 0 ) $ld++ ; 
 $nn=0; 
 $n=1; 
 $aujourduis = date("Y-m-d", time() ); 
 echo ""; 
 while ( $n < $ld ) 
 { 
 if ( ( ++$nn >= $firstwday ) ) 
 { 
 $value = date("Y-m-d", $tbuff); 
 if ( ( $value> $beg && $value< $end ) || 
 (($this->me ==1 ) && ( $value== $end ) ) || 
 (($this->me ==2 ) && ( $value== $beg ) )) 
 { 
 echo "| " ; 
 } 
 elseif ( ( ($value == $beg) && ($this->me ==1 ) ) 
 || (( $value == $end) && ( $this->me ==2 ) ) ) 
 { 
 echo " | " ; 
 } 
 else { echo " | " ; } 
 $d = beg ; 
 $f = $end ; 
 if ($this->me == 1 ) { $d = $value ; 
 if ( $d > $end ) { $f = $d ; } 
 else { $f = $end ; } } 
 else 
 { $f = $value ; 
 if ( $f < $beg ) { $d = $f ; } 
 else { $d = $beg ; } } 
 if($value >= $aujourduis ) 
 echo "  ".$n."" ; 
 else echo $n. "" ; 
 ++$n; 
 $tbuff +=86400 ; 
 } 
 else 
 { 
 echo " | ?" ; 
 } 
 if ( $nn % 7 ==0 ) echo " | 
 "; 
 } 
echo "
"; 
} 
function draw ( $goto , $c1 , $c2 ) 
{ 
global $time , $beg , $end , $cal ; 
setlocale ("LC_ALL", "fr_CA"); 
echo " \n \n 
| " ; 
if ( $this->me ==1 ) 
{ 
echo "  
 <<\n | ".strftime(" %B %Y" ,$c1 ) ."\n | >>\n" ; 
} 
else 
{ 
echo "  
 <<   \n | ". strftime(" %B %Y" ,$c2 ) ."\n | >>\n " ; 
} 
echo " | 
  
|  
| L | M | M | J | V | S | D"; 
$this->jj( $goto , $c1 , $c2 ) ; 
echo " | 
|---|
 | 
 "; 
} 
} 
// USAGE ( CODE fragment ) 
// if( ! defined ("BZ_calendar") ) include "lib/BZ_calendar.inc"; 
// if ( $time=='' ) $time = time(); 
// if ( !isset ($c1 )) $c1 = $time ; 
// if ( !isset ($c2 )) $c2 = $time ; 
// if (!isset ( $beg ) ) $beg = date("Y-m-d", $time); 
// if (!isset ( $end ) ) $end = date("Y-m-d", $time); 
// if ( $cal == 1 && $c2 < $c1 ) $c2 = $c1 ; 
// if ( $cal == 2 && $c2 < $c1 ) $c1 = $c2 ; 
// $cal1= new BZ_calendar ( 1 , $beg , $end ) ; 
// $cal2 = new BZ_calendar ( 2 , $beg , $end ) ; 
// 
// $cal1->draw("test.php3" , $c1 ,$c2 ); 
// 
// $cal2->draw("test.php3" , $c1 ,$c2 ); 
/// the first calendar select the start date , the second the end date ) 
// The query the database whith $beg and $end 
// enjoy ( but you have to change it a little to use the US date format )