/////here's the code
//code is not complete, but shows the logic
//lacks features select another date
if (isset($_GET['id'])) {
$id = $_GET['id'];
}
else echo 'no id';
///id=11;
if ($id)
{
$q = "SELECT `id`, `Mon`, `Tue`, `Wed`, `Thu`, `Fri`, `Sat`, `Sun`, `Mon-Time-St`, `Mon-Time-En`, `Tue-Time-St`,
`Tue-Time-En`, `Wed-Time-St`, `Wed-Time-En`, `Thu-Time-St`, `Thu-Time-En`, `Fri-Time-St`, `Fri-Time-En`,
`Sat-Time-St`, `Sat-Time-En`, `Sun-Time-St`, `Sun-Time-En` FROM `data` where id = ".$id." LIMIT 1" ;
$result = mysqli_query($connect,$q);
if (mysqli_num_rows($result))
{
$data = mysqli_fetch_array($result);
$day_week = date('D',time());
$cur_day_result = $data[$day_week];
$result_array['Now'] = $cur_day_result;
if ($cur_day_result==1)///online
{
///work time
$work_time_st = $data[$day_week.'-Time-St'];
$work_time_en = $data[$day_week.'-Time-En'];
///to absolute time
$atime_start = strtotime($work_time_st);
$atime_end = strtotime($work_time_en);
if (time()<$atime_start)
{
$result_array['DoW'] = 'office will be open at '.$atime_start;
}
else if (time()>$atime_start && time()<$atime_end)
{
$result_array['DoW'] = 'office is open ';
}
else if ( time()>$atime_end)
{
$result_array['DoW'] = 'office is closed ';
////find next day
//
//////////////here I shall add if you take my request
}
}
}
$res = json_encode($result_array);
echo $res;
///{"Now":"1","DoW":"office will be open at 1470967200"}
}