'$new_date' order by id asc "; $Query_job_move_free_job = mysqli_query($conn, "SELECT * from tbl_doctor_appointment where date='$new_date' and date >='$new_date' order by id asc "); $num_rows_mal = mysqli_num_rows($Query_job_move_free_job); $k=0; if($num_rows_mal>0) { $si=0; while($row_job_move_free_job = mysqli_fetch_array($Query_job_move_free_job)) { $new_id=$row_job_move_free_job['id']; $from_hour=$row_job_move_free_job['from_hour']; $from_hour_1 = sprintf("%02d", $from_hour); $from_min=$row_job_move_free_job['from_min']; $from_min_1 = sprintf("%02d", $from_min); $from_sta=$row_job_move_free_job['from_sta']; $to_hour=$row_job_move_free_job['to_hour']; $to_hour_1 = sprintf("%02d", $to_hour); $to_min=$row_job_move_free_job['to_min']; $to_min_1 = sprintf("%02d", $to_min); $to_sta=$row_job_move_free_job['to_sta']; $new_date=$row_job_move_free_job['date']; $time=strtotime($new_date); $month=date("F",$time); $year=date("Y",$time); $new_date_1=date('D', strtotime($new_date)); $new_date_m=date('M', strtotime($new_date)); $new_date_m_mas=date('d', strtotime($new_date)); $selectedTime = ''.$from_hour_1.':'.$from_min_1.' '.$from_sta.''; $selectedTime2 = ''.$to_hour_1.':'.$to_min_1.' '.$to_sta.''; $endTime = strtotime("+20 minutes", strtotime($selectedTime)); /*echo $newtime1=date('h:i a', $selectedTime); $newtime2=date('h:i a', $selectedTime2);*/ $loginTime = strtotime($selectedTime); $checkTime = strtotime($selectedTime2); $diff = $checkTime - $loginTime; $newdif=round($diff/1200); $new_time_ma=$selectedTime = ''.$from_hour_1.':'.$from_min_1.' '.$from_sta.''; $new_time_ma_1=strtotime($new_time_ma); for($i=0;$i<=$newdif;$i++) { $new_1=date('Y-m-d', strtotime($new_date)); $iy_h= date('h', $new_time_ma_1); $iy_m= date('i', $new_time_ma_1); $iy_am= date('a', $new_time_ma_1); $obj_1 = mysqli_query($conn, "SELECT id from tbl_appointment where appointment_date='$new_1' and hour_date='$iy_h' and min_date='$iy_m' and am_date='$iy_am' and status='1' "); // echo "SELECT id from tbl_appointment where appointment_date='$new_1' and hour_date='$iy_h' and min_date='$iy_m' and am_date='$iy_am' and status='1' "; $num_1 = mysqli_num_rows($obj_1); if($num_1==0) { $k=$k+1; } $new_time_ma_1 = strtotime("+20 minutes", $new_time_ma_1); } $si=$si+1; } } if($k > 0){ return $k; }else{ return $k=0; } } ?>