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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • superjohnellee
    New Member
    • Sep 2020
    • 2

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

    Code:
    function create_time_range($start, $end, $interval='30 mins', $format='12'){
    	$startTime=strtotime($start);
    	$endTime=strtotime($end);
    	$returnTimeFormat=($format=='24')?'g:i':'G:i';
    
    	$current=time();
    	$addTime=strtotime('+'.$interval,$current);
    	$diff=$addTime-$current;
    
    	$times=array();
    	while ($startTime<$endTime) {
    		$times[]=date($returnTimeFormat,$startTime);
    		$startTime+=$diff;
    	}
    	$times[]=date($returnTimeFormat,$startTime);
    	return $times;
    }
    
    <div class="table-responsive">
                    <form method="POST">
    	                <table class="table table-bordered table-hoverable table-striped" id="tblClassScheduler">
    	                    <thead>
    	                       <tr>
    	                         <?php
    	                          $days=array("Monday"=>1,"Tuesday"=>2,"Wednesday"=>3,"Thursday"=>4,"Friday"=>5,"Saturday"=>6,"Sunday"=>7);
    	                          for ($i=0;$i<COUNT($days);$i++) { 
    	                            echo "<th>".date("D m/d",strtotime(" +".$i." days"))."</th>";
    	                          }
    	                       ?>
    	                       </tr>
    	                    </thead>
    	                    <tbody>
    	                    	<?php
    	                    		$class_time=create_time_range('08:00','22:00','30 mins');
    	                    		$j=0;
    	                    		foreach ($class_time as $value) {
    	                    			$j++;
    	                    			echo "<tr>
    	                    				<td>".$value."<br><input type='checkbox' name='class_time_mon".$j."' value='".$value."'></td>
    	                    				<td>".$value."<br><input type='checkbox' name='class_time_tues".$j."' value='".$value."'></td>
    	                    				<td>".$value."<br><input type='checkbox' name='class_time_wed".$j."' value='".$value."'></td>
    	                    				<td>".$value."<br><input type='checkbox' name='class_time_thurs".$j."' value='".$value."'></td>
    	                    				<td>".$value."<br><input type='checkbox' name='class_time_fri".$j."' value='".$value."'></td>
    	                    				<td>".$value."<br><input type='checkbox' name='class_time_sat".$j."' value='".$value."'></td>
    	                    				<td>".$value."<br><input type='checkbox' name='class_time_sun".$j."' value='".$value."'></td>
    	                    			</tr>";
    	                    		}
    	                    	?>
    	                    </tbody>
    	                    <button type="submit" class="btn btn-primary" id="save_class_schedule" name="save_class_schedule">Save</button>
    	                </table>
                    </form>
                </div>
Working...