Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.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_Css - Fatal编程技术网

PHP日历的问题

PHP日历的问题,php,css,Php,Css,因此,我使用php类制作了一个日历,它可以正常工作,除非一个月的第一天是星期六(两个例子是2020年2月1日或2020年8月1日)。我相信问题出在PHP类中,但我将包括CSS,以及一些正在发生的事情的屏幕截图 PHP 问题实际上在CSS中 新CSS代码段 .calCol-1{ 宽度:14.27%; } .calCol-2{ 宽度:28.56%; } .calCol-3{ 宽度:42.85%; } .calCol-4{ 宽度:57.14%; } .calCol-5{ 宽度:71.43%; } .

因此,我使用php类制作了一个日历,它可以正常工作,除非一个月的第一天是星期六(两个例子是2020年2月1日或2020年8月1日)。我相信问题出在PHP类中,但我将包括CSS,以及一些正在发生的事情的屏幕截图

PHP


问题实际上在CSS中

新CSS代码段

.calCol-1{
宽度:14.27%;
}
.calCol-2{
宽度:28.56%;
}
.calCol-3{
宽度:42.85%;
}
.calCol-4{
宽度:57.14%;
}
.calCol-5{
宽度:71.43%;
}
.calCol-6{
宽度:85.72%;
}
.calCol-7{
宽度:99.98%;

}
您是否进行过任何调试,试图缩小问题的范围?能否提供调用
日历的PHP代码
构造函数?特别是2020年2月。看到呈现的HTML与之对应(图像很好,但HTML更好)也会很好。我已经更新了帖子,以包含更多的代码,包括使用的jquery。我没有包括php sql查询,因为它们与问题无关。我很确定问题在课堂上。如果你还需要什么,请告诉我。我当然是个业余爱好者。当我查看firefox的inspector时,2月1日应该占据的空间并没有突出显示出来。它与它的父对象一起高亮显示,但如果这有意义的话,它不会像兄弟姐妹一样高亮显示。
error_reporting(E_ALL);
ini_set('display_errors', 1);

class Calendar{

    private $month;
    private $year;
    private $days_of_week;
    private $num_days;
    private $date_info;
    private $day_of_week;

    public function __construct($month, $year, $days_of_week = array('Sun','Mon','Tue','Wed','Thu','Fri','Sat')){

       // server info would be here.

        require_once(CONN_DB);
        require_once(SESH);

        $this->month = $month;
        $this->year = $year;
        $this->days_of_week = $days_of_week;
        $this->num_days = cal_days_in_month(CAL_GREGORIAN, $this->month, $this->year);
        $this->date_info = getdate(strtotime('first day of', mktime(0,0,0,$this->month,1,$this->year)));
        $this->day_of_week = $this->date_info['wday'];          

    }

    public function show($conn){
        $output = '<div class="calRow">';

        foreach($this->days_of_week as $day){

            $output .= '<div class="calCol-1 header">'.$day.'</div>';

        }

        $output .= '</div>';
        $output .= '<div class="calRow dayRow">';

        if($this->day_of_week > 0){

            $output .= '<div class="calCol-'.$this->day_of_week.' empty"></div>';

        }
        //This is where I think the issue is...
        $current_day = 1;

        while($current_day <= $this->num_days){

            if($this->day_of_week == 7){
                $this->day_of_week = 0;
                $output .= '</div><div class="calRow dayRow">';
            }

            $day_date = str_pad($current_day,2,'0',STR_PAD_LEFT);
            $mnth_w_zero = str_pad($this->month,2,'0',STR_PAD_LEFT);
            $event_date = $this->year . '-' . $mnth_w_zero . '-' . $day_date;

            $output .= '<div class="calCol-1 day">';

                $output .= '<div class="date">'.$day_date.'</div>';
                $output .= '<div class="slots" id="'.$event_date.'"></div>';

            $output .= '</div>';

            $current_day++;
            $this->day_of_week++;
        }

        // bottom of issue spot...

        if($this->day_of_week != 7){
            $remaining_days = 7 - $this->day_of_week;
            $output .= '<div class="calCol-'.$remaining_days.' empty"></div>';
        }

        $output .= '</div>';

        echo $output;
    }

}