title: Having trouble with creating a timetable
body: <p>I am attempting to make a timetable using data in a MySQL table that has the day, start and durtaion of each event.</p>
  
  <p>My logic at the moment goes like this.</p>
  
  <p>Find all events with monday, put in an array for monday
  Find all events with tuesday, put in an array for tuesday</p>
  
  <p>etc</p>
  
  <p>then i run a for each loop on each array to go through each time slot in the day (9-5) and if it matches the current event, create a table cell, if not create and empty cell and finally if the event duration is longer than 1 slott then dont put anything. here is my code for the above:</p>
  
  <pre><code>function createTableEvent($day,$previousfinish)
  {
  $completeDay = '';
  $day = explode(',',$day);
  
          $ev = $day[0];
          $start = $day[1];
          $end =  $day[2];
          $event = "&lt;div class=\"table_event\"&gt;$ev&lt;br&gt;Starts:$start&lt;br&gt;Ends:$end&lt;br&gt;&lt;/div&gt;";
  
      $times= array('09','10','11','12','13','14','15','16','17');
  
      //TIMES
      foreach ($times as $time)
      {
  
  
           if($start == $time.":00" &amp;&amp; $previousfinish == !)
            {
          $completeDay .= "&lt;td class=\"$time\" colspan=\"$end\"&gt;
                  &lt;div class=\"table_event\"&gt;$event&lt;/div&gt;&lt;/td&gt;"; 
          $previousfinish = $end;
            } 
           else if($previousfinish &gt; 1
               {
               }
                else
          {
          $completeDay .= "&lt;td class=\"$time\" colspan=\"1\"&gt;&lt;/td&gt;"; 
          }
  
      }   
          return $completeDay;        
  
  }
  </code></pre>
  
  <p>The reason i wanna skip the cell if it is more than 1 is because if an event runs over more than one block, i set the column span to the duration of the event, there for it shhouldnt put a cell in for the next time if the previous event was longer than one block.</p>
  
  <p>My output works for single hour events however not when a day has say 1 2 hour event and a 2nd 1 hour event. My code still makes the extra cells for the times that should be empty.</p>
  
  <p>Any input or help would be very useful</p>