Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/241.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 使用td colspan将表项向右对齐?(HTML)_Php_Html_Html Table - Fatal编程技术网

Php 使用td colspan将表项向右对齐?(HTML)

Php 使用td colspan将表项向右对齐?(HTML),php,html,html-table,Php,Html,Html Table,所以基本上我用PHP和HTML创建了一个日历。所有的日期都存储在一个表中。但是当我在localhost浏览器中呈现日历时,colspan函数在第一行似乎不起作用,它从一开始就开始了,尽管日历的其余部分排列得很好 您可以看到,第一行元素并没有向右对齐,这是普通日历所能做到的,即使我在它上面使用了colspan 代码如下: $output = '<table class = "Calendar">'; //The Calendar is a tab

所以基本上我用PHP和HTML创建了一个日历。所有的日期都存储在一个表中。但是当我在localhost浏览器中呈现日历时,colspan函数在第一行似乎不起作用,它从一开始就开始了,尽管日历的其余部分排列得很好

您可以看到,第一行元素并没有向右对齐,这是普通日历所能做到的,即使我在它上面使用了colspan

代码如下:


    $output = '<table class = "Calendar">';     //The Calendar is a table instead of being made of individual items.

    $output .= '<caption class = "monthName">' . $this->date_info ['month'] . ' ' . $this->year . '</caption>';
    $output .= '<tr>';    //new table row

    //creates days of the week header for each day in the array
    foreach ( $this->weekdays as $days ){   //for every day in the weekdays array, setting each of them AS a day ($day)
      $output .= '<th class = "header">' . $days . '</th>';
    }

    //IF the first day of a month doesnt fall on a sunday then use COLSPAN to fill the BEGINNING SPACE
    if ($this->dayOfWeek > 0){
      $output .= '<td colspan="' . $this->dayOfWeek . '"></td>';
    }

    //Start the num_days counter
    $output .= '<tr></tr>';   //space calender BELOW the days
    $current_day = 1;```


(later code)
```  //Increment counters
    $current_day++;
    $this->dayOfWeek++;

    }
    // Once num_days counter stops, if day of week counter is not 7, then fill the remaining space on the row uing COLSPAN
    if ($this->dayOfWeek != 7) {    //Resets at 7
      $remaining_days = 7 - $this->dayOfWeek;    //Amount of remaining days in the week
      $output .= '<td colspan="' . $remaining_days .'"></td>';   //span for the remaining days in the week
    }
    //Close final row, close table

    $output .= '</tr>';
    $output .= '</table>';

$output=''//日历是一个表格,而不是由单个项目组成。
$output.=''$此->日期信息['month'.]$今年",;
$output.=''//新表行
//为阵列中的每一天创建周中的天数标头
foreach($this->weekdays as$days){//for weekdays数组中的每一天,将每一天设置为一天($day)
$output.=''.$days';
}
//如果一个月的第一天不是星期天,那么使用COLSPAN填充开始的空间
如果($this->dayOfWeek>0){
$output.='';
}
//启动num_days计数器
$output.=''//天以下的太空日历
$current_day=1```
(后代码)
```//递增计数器
$current_day++;
$this->dayOfWeek++;
}
//一旦num_days计数器停止,如果day of week计数器不是7,则填充uing COLSPAN行上的剩余空间
如果($this->dayOfWeek!=7){//重置为7
$leveling_days=7-$this->dayOfWeek;//一周中剩余天数的数量
$output.='';//一周中剩余天数的范围
}
//关闭最后一行,关闭表格
$output.='';
$output.='';

设置的
$this->dayOfWeek
在哪里?它还看起来像是在创建空白的前导td之后立即创建一个空行,这样就可以从头开始了。我很困惑。当您查看页面的html源代码时,第一行及其单元格的顺序是否正确?您的
标记没有按有效顺序生成,请检查生成的html,这应该会有帮助````this->dayOfWeek=$this->date\u info['wday'//获取信息,包括一周中的哪一天