我想创建一个表,而不是可以用现有数据输入,并且表甚至在输入数据之前就已存在,表基于本月的天数创建(即:现在是10月所以它有31个表从10月开始有31天)。
问题是我想将日期编号放在列日期和列天中的日期,基本上date =1
所以days of week=saturday
,date =2
所以days of week=sunday
(基于当前日历) )等等
我不太确定逻辑,因为每次我尝试时,它只填充第一个div
或填充整个div
检查下面的代码
CODE
<table class="table table-bordered">
<thead>
<tr>
<th rowspan="2">Action</th>
<th rowspan="2">Date</th>
<th rowspan="2">Day of Week</th>
<th rowspan="2">Location</th>
<th rowspan="2">Brief Description of Activity </th>
<th colspan="6"><center>Project Code & Hour Worked</center> </th>
</tr>
<tr>
<th>A</th>
<th>Hours Worked</th>
<th>B</th>
<th>Hours Worked</th>
<th>C</th>
<th>Hours Worked</th>
</tr>
</thead>
<tbody>
<?php
$start = new DateTime('first day of this month');
$end = new DateTime('first day of this month + 1 month');
$period = new DatePeriod($start, new DateInterval('P1D'), $end);
for($i= 1; $i < date('t') + 1; $i++){
for($j =1;$j<=1;$j++){
echo "<td><a href='#modal-dialog' class='btn btn-xs btn-success' data-toggle='modal'><span class='fa fa-pencil'></span>i=".$i."</td>".PHP_EOL;
}
for($j =2;$j<=2;$j++){
foreach($period as $day){
echo "<td>".$day->format('M-d')."</td>".PHP_EOL;
}
for($j =1;$j<11;$j++){
echo "<td></td>".PHP_EOL;;
}
echo "</tr>";
}
?>
</tbody>
答案 0 :(得分:1)
你做错了。你循环遍历这些日子并构建列。你的日常循环应该构建行。
@IBAction func EDB(sender: UITextField) {
performSelector(#selector(selectRange), withObject: nil, afterDelay: 0.01)
}
@objc private func selectRange() {
let startPosition = textField.beginningOfDocument
let endPosition = textField.endOfDocument
textField.selectedTextRange = textField.textRange(from: startPosition, to: endPosition)
}