|  | Posted by Joseph Melnick on 06/14/05 15:51 
Hello Hans,
 Hello Hans,
 
 I wrote an example for you which takes year and month as input and number of
 availible seats from an array and displays a formatted calendar. If no year
 or month is given then the current  year or month is assumed.
 
 I hope that this helps.
 
 Joseph Melnick
 JM Web Consultants
 http://www.jphp.com/
 
 <?php
 // calendar creation for Hans Funk
 // year month
 
 $year  = (array_key_exists('year',$_REQUEST))?$_REQUEST['year']:date("Y");
 $month = (array_key_exists('month',$_REQUEST))?$_REQUEST['month']:date("n");
 
 function first_day($year,$month) {
 $first_day_of_week = date("w",mktime(0, 0, 0, $month, 1, $year));
 return $first_day_of_week;
 }
 
 function days_in_month ($year,$month) {
 $daysinmonth = date("t",mktime(0, 0, 0, $month, 1, $year));
 return $daysinmonth;
 }
 
 $fd_index = first_day($year,$month);
 $daysinmonth = days_in_month ($year,$month);
 $daysleft = $daysinmonth - (7 - $fd_index);
 $weeks = (($daysleft/7) > 4)?5: (((($daysleft/7) > 3) and (($daysleft/7)
 <=4 )))  ?4:3;
 
 $day = 0;
 
 // could get this list from your database
 $availableseats = array(
 5,3,4,3,2,1,2,3,4,5,6,7,2,3,4,3,2,3,4,5,6,4,2,3,4,5,4,3,2,3,4,1);
 
 echo "<table>";
 echo "<tr>";
 for($i=0;$i<7;$i++){
 if($i>=$fd_index) {
 $day++;
 echo '<td style="background-color: red; border: 1px solid
 black;"> '.$day.'  '.$availableseats[$day].'</td>';
 }
 else echo '<td style="border: 1px solid black;"> </td>';
 }
 
 $day++;
 
 echo "</tr>";
 for($j=0; $j<=$weeks; $j++) {
 echo "<tr>";
 for($i=0;$i<7;$i++,$day++){
 if($day <= $daysinmonth) {
 echo '<td style="background-color: red; border: 1px solid
 black;"> '.$day.' '.$availableseats[$day].'</td>';
 } else {
 echo '<td style="border: 1px solid black;"> </td>';
 }
 }
 echo "</tr>";
 }
 echo "</table>";
 ?>
 
 
 
 
 
 "Hans Funk" <hf4444@hotmail.com> wrote in message
 news:42ae7fab$0$1154$5402220f@news.sunrise.ch...
 > Hi NG
 >
 > I have a site to book balloon flights in Thailand online.
 > http://www.thaiballoons.com/autolisteneu.php
 >
 > The customer can look up available seats and book them at once online.
 > This is working perfectly, BUT ...
 > I don't like the look of that long listing of remaining and available
 > seats.
 >
 > I would like it to look more professional - like in all the online flight
 > booking sites:
 > The customer enters a date and then the available seats are shown.
 > As an addition maybe we could allso show a specific number of days before
 > and after the
 > selected date.
 >
 > Who can help??
 > As i say, the booking runs perfect - it's only the look that needs
 > improvement.
 >
 > Please reply in this NG or contact me here: funks(at)ggs(dot)ch
 > Could you give me, at this stage, an estimate of how much this will cost
 > me
 > about?
 >
 > Thanks for your help
 > Hans
 >
 >
  Navigation: [Reply to this message] |