Public paste
Undefined
By: Guest | Date: Dec 6 2009 19:24 | Format: PHP | Expires: never | Size: 1.53 KB | Hits: 769

  1. <?php
  2. /*
  3.  * This is generating the date's (horizontal)
  4.  */
  5.  
  6. echo '<body>';
  7. echo '<table class="rooster">';
  8. echo '  <tr>';
  9. echo '  <td width="20" class="roosterDate"></td>';
  10.  
  11. $firstday = 1;
  12. $thismonth = mktime(0, 0, 0, date("m"), 1, date("Y"));
  13. $lastday = date("t", $thismonth);
  14.  
  15. while ($firstday <= $lastday) {
  16.         echo '<td width="35" class="roosterDate">';
  17.         echo $firstday .'-'. date("m");
  18.         echo '<br />';
  19.         $dayname = mktime(0, 0, 0, date("m"), $firstday, date("Y"));
  20.         echo date("D", $dayname);
  21.         echo '</td>';
  22.         $firstday++;
  23. }
  24.  
  25. echo '</tr>';
  26.  
  27.  
  28.  
  29. /*
  30.  * This is getting the data from the database and storing in an array
  31.  */
  32.  
  33. $roosterQuery   = mysql_query("SELECT `month`, `day`, `hour`, `availability` FROM `rooster` WHERE `month` = '12' AND `availability` = '1'");
  34.  
  35. while ($data = mysql_fetch_assoc($roosterQuery)) {
  36.         $month  = $data["month"];
  37.         $day    = $data["day"];
  38.         $hour   = $data["hour"];
  39.         $avail  = $data["availability"];
  40.        
  41.         $aData[] = array("month" => $month, "day" => $day, "hour" => $hour, "avail" => $avail);
  42. }
  43.  
  44.  
  45.  
  46. /*
  47.  * This is generating the hours (vertical)
  48.  */
  49.  
  50. $hour = 0;
  51. while ($hour <= 23) {
  52.         echo '<tr>';
  53.         echo '<td width="20" class="roosterTD">';
  54.         echo $hour;
  55.         echo '</td>';
  56.         $firstday = 1;
  57.         $thismonth = mktime(0, 0, 0, date("m"), 1, date("Y"));
  58.         $lastday = date("t", $thismonth);
  59.  
  60.         while ($firstday <= $lastday) {
  61.                 echo '<td width="35" class="roosterTD">';
  62.                 //echo $firstday .'-'. $hour;
  63.                 echo 'x';
  64.                 echo '</td>';
  65.                 $firstday++;
  66.         }
  67.         echo '</tr>';
  68.         $hour++;
  69. }
  70.  
  71. echo '</table>'
  72. ?>