Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/60.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 预定时段_Php_Mysql - Fatal编程技术网

Php 预定时段

Php 预定时段,php,mysql,Php,Mysql,我正在做一个php mysql项目,它需要一个预订应用程序,但是我遇到了一个挑战,那就是抽出所有预订的时间段,只显示这段时间的可用时间 所以基本上,如果有人从09:15:00预订到09:30:00,它应该显示从08:00:00(日期开始时间)到09:15:00(预订开始时间)的可用时间,然后再次显示下一个时间段从09:30:00到18:00:00(日期结束时间) 函数createForAvailableHrs($FirstStartTime、$lastEndTime、$date) { $conn

我正在做一个php mysql项目,它需要一个预订应用程序,但是我遇到了一个挑战,那就是抽出所有预订的时间段,只显示这段时间的可用时间

所以基本上,如果有人从09:15:00预订到09:30:00,它应该显示从08:00:00(日期开始时间)到09:15:00(预订开始时间)的可用时间,然后再次显示下一个时间段从09:30:00到18:00:00(日期结束时间)

函数createForAvailableHrs($FirstStartTime、$lastEndTime、$date)
{
$connector=新的DbConnector();
$this_date=日期(“Y-m-d”,标准时间($date[1]);
$result=$connector->query(“从GPC_约会中选择*,其中deletedBy=?和appointmentDate=?”,数组(0,$this_date));
$rowCount=$connector->num\u结果($result);
如果($rowCount>0){
$count=$connector->num\u结果($result);
$c=0;
$show='';
$newStartTime='';
$lastNewEndTime='';
而($row=$connector->fetchArray($result))
{ 
//设置新的检查时间点
如果($row['appointmentTimeFrom']!=''){
//如果预订时间少于开始时间
$endTime=$row['appointmentTimeTo'];
$startTime=$row['appointmentTimeFrom'];
如果($newStartTime==''){$newStartTime=$FirstStartTime;}
//如果预订时间少于开始时间
如果($this->dateDiffInterval($endTime,$startTime,'H')<2{$endTime=$this->AdjustEndTime($startTime);}
//如果预订结束时间大于2小时
如果(abs($this->dateDiffInterval($endTime,$startTime,'H'))>=2){$startTime=$this->AdjustEndTime($startTime);}
如果($this->getNextEndTime($startTime,$date)!==FALSE&&$this->getNextEndTime($startTime,$date)!==null){//next startTime是>“15分钟”,newEndTime=nextStartTime
//$newEndTime=$endTime;//+strottime($this->getNextEndTime($startTime,$date));
$newEndTime=$this->AdjustEndTime($endTime,$this->getNextEndTime($startTime,$date));
}
否则{
$newEndTime=$this->AdjustEndTime($endTime,”);
}
如果($endTime>$FirstStartTime){
$newEndTime=$startTime;//日期(“H:i:s”,strotime(“+15分钟,$startTime))$endTime;
$endTime=$FirstStartTime;
}
如果(date(“H:i:s”,strotime($newStartTime))>date(“H:i:s,strotime($FirstStartTime))){$startTime=$FirstStartTime;}
$show.=''。
$endTime.“上午到”$newEndTime.“;
}
$c++;
如果($c==$count){
$show.=$this->createForStandardWorkHrs($date,$newEndTime);
}
}
返回$show;
}
否则{
返回FALSE;
}
}

目前,这一切都没有达到预期的效果,有什么帮助吗?

如果是我,我现在就忘了PHP,而是专注于MySQLIs这个问题类似于你的问题?也许有趣。
function createForAvailableHrs($FirstStartTime, $lastEndTime, $date)
{
    $connector      = new DbConnector();

    $this_date = date("Y-m-d", strtotime($date[1]));
    $result = $connector->query("SELECT * FROM GPC_appointments WHERE deletedBy = ? AND appointmentDate = ?", array(0,$this_date));
    $rowCount = $connector->num_results($result);

    if($rowCount > 0) {

        $count = $connector->num_results($result);
        $c = 0;
        $show = '';
        $newStartTime = '';
        $lastNewEndTime = '';

        while ($row = $connector->fetchArray($result))
        { 

                //Set New check time points

                if ($row['appointmentTimeFrom'] !== '') {
                    //IF BOOKING IS LESS THAN START TIME
                    $endTime = $row['appointmentTimeTo'];
                    $startTime = $row['appointmentTimeFrom'];

                    if($newStartTime == '') { $newStartTime = $FirstStartTime; }

                    //IF BOOKING IS LESS THAN START TIME
                    if ($this->dateDiffInterval($endTime, $startTime, 'H') < 2) { $endTime = $this->AdjustEndTime($startTime); }

                    //IF BOOKING END TIME IS GREATER THAN 2 HOURS
                    if (abs($this->dateDiffInterval($endTime, $startTime, 'H')) >= 2) { $startTime = $this->AdjustEndTime($startTime); }
                     if($this->getNextEndTime($startTime,$date) !== FALSE && $this->getNextEndTime($startTime,$date) !== null) { //next startTime is > "15 min", newEndTime = nextStartTime
                        //$newEndTime = $endTime;// + strtotime($this->getNextEndTime($startTime,$date));
                        $newEndTime = $this->AdjustEndTime($endTime, $this->getNextEndTime($startTime,$date));
                     }
                     else {
                        $newEndTime = $this->AdjustEndTime($endTime, '');
                     }

                     if ($endTime > $FirstStartTime) {
                         $newEndTime = $startTime;//date("H:i:s",strtotime("+ 15 minutes",$startTime))$endTime;
                         $endTime = $FirstStartTime;
                     }

                    if (date("H:i:s", strtotime($newStartTime)) > date("H:i:s", strtotime($FirstStartTime))) { $startTime = $FirstStartTime; }

                    $show .= "<div class='bookingSlots' data-bookingFromHours='".$endTime."' "
                            . "data-timeDiff='".abs($this->dateDiffInterval($endTime, $newEndTime, 'H'))."' "
                            . "data-bookingToHours='".$newEndTime."' data-bookdate='$date[1]'>".
                            $endTime. " am to ".$newEndTime."  </div>";
                }

            $c++;
            if ($c == $count) {
                $show .= $this->createForStandardWorkHrs($date, $newEndTime);
            }
        }

        return $show;
    }
    else {
        return FALSE;
    }

}