467,913 Members | 1,798 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,913 developers. It's quick & easy.

Developing a class plotting scheduler but it has many logical errors, Can you help me

Expand|Select|Wrap|Line Numbers
  1. function create_time_range($start, $end, $interval='30 mins', $format='12'){
  2.     $startTime=strtotime($start);
  3.     $endTime=strtotime($end);
  4.     $returnTimeFormat=($format=='24')?'g:i':'G:i';
  5.  
  6.     $current=time();
  7.     $addTime=strtotime('+'.$interval,$current);
  8.     $diff=$addTime-$current;
  9.  
  10.     $times=array();
  11.     while ($startTime<$endTime) {
  12.         $times[]=date($returnTimeFormat,$startTime);
  13.         $startTime+=$diff;
  14.     }
  15.     $times[]=date($returnTimeFormat,$startTime);
  16.     return $times;
  17. }
  18.  
  19. <div class="table-responsive">
  20.                 <form method="POST">
  21.                     <table class="table table-bordered table-hoverable table-striped" id="tblClassScheduler">
  22.                         <thead>
  23.                            <tr>
  24.                              <?php
  25.                               $days=array("Monday"=>1,"Tuesday"=>2,"Wednesday"=>3,"Thursday"=>4,"Friday"=>5,"Saturday"=>6,"Sunday"=>7);
  26.                               for ($i=0;$i<COUNT($days);$i++) { 
  27.                                 echo "<th>".date("D m/d",strtotime(" +".$i." days"))."</th>";
  28.                               }
  29.                            ?>
  30.                            </tr>
  31.                         </thead>
  32.                         <tbody>
  33.                             <?php
  34.                                 $class_time=create_time_range('08:00','22:00','30 mins');
  35.                                 $j=0;
  36.                                 foreach ($class_time as $value) {
  37.                                     $j++;
  38.                                     echo "<tr>
  39.                                         <td>".$value."<br><input type='checkbox' name='class_time_mon".$j."' value='".$value."'></td>
  40.                                         <td>".$value."<br><input type='checkbox' name='class_time_tues".$j."' value='".$value."'></td>
  41.                                         <td>".$value."<br><input type='checkbox' name='class_time_wed".$j."' value='".$value."'></td>
  42.                                         <td>".$value."<br><input type='checkbox' name='class_time_thurs".$j."' value='".$value."'></td>
  43.                                         <td>".$value."<br><input type='checkbox' name='class_time_fri".$j."' value='".$value."'></td>
  44.                                         <td>".$value."<br><input type='checkbox' name='class_time_sat".$j."' value='".$value."'></td>
  45.                                         <td>".$value."<br><input type='checkbox' name='class_time_sun".$j."' value='".$value."'></td>
  46.                                     </tr>";
  47.                                 }
  48.                             ?>
  49.                         </tbody>
  50.                         <button type="submit" class="btn btn-primary" id="save_class_schedule" name="save_class_schedule">Save</button>
  51.                     </table>
  52.                 </form>
  53.             </div>
Sep 25 '20 #1
  • viewed: 1363
Share:

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

By using this site, you agree to our Privacy Policy and Terms of Use.