我想打印本周的表格,其中包含您每天必须执行的任务,但是由于某些原因,任务栏的第一个值打印在表格上方,第二个值显示在第一个任务单元格中。因此,最后一列的最后一个单元格始终为空。我该如何解决?
$weekdagen = ["maandag","dinsdag","woensdag","donderdag","vrijdag","zaterdag","zondag"];
//today
$vandaag = date("d-m-Y",time());
//day of week starting on Monday (-1)
$weekdag = date('w', strtotime($vandaag)) -1;
$i = 0;
//get first day of this week
$startWeek = date('Y-m-d', strtotime('-'.($weekdag).' days'));
$datum = $startWeek;
while($i<7)
{
print '<tr>
<td>'.$weekdagen[$i+1].'</td>
<td>'.$datum.'</td>
<td>' .printTasks($datum); '</td>
</tr>';
$i++;
$datum = date('Y-m-d', strtotime($datum.' +1 days'));
}
function printTasks($date) {
$sql = "SELECT taa_omschr FROM taken where taa_datum = '".$date."'";
$res = SQLexec($sql);
while($row = $res->fetch_assoc()) { print $row[taa_omschr] . '<br>'; }
}
我将SQL语句更改为$ date-1天,因此在正确的日期旁边显示了正确的任务,但是它不能解决最后一个单元格为空的问题。