我创建了当月的日历,但我还需要检查数据库中是否存在同一月份和年份的行。并且比如果显示那天的工作时间行。这是我的代码
echo '
<table class="table table-hover">
<thead>
<tr>
<th>Date</th>
<th>Hours</th>
<th>Minutes</th>
<th></th>
</tr>
</thead>
<tbody class="listUser">';
//get how many day on the month
$daysOfMonth = date('t', strtotime("$month/1/$year"));
//select all from the db
$result = $this->_dbconn->prepare('SELECT time.day, time.hours, time.minutes FROM work_time AS time WHERE year=? AND month=?');
$result->execute(array($year, $month));
$rows = $result->fetchAll(PDO::FETCH_ASSOC);
//printVar($rows);
for($i=1; $i<$daysOfMonth; $i++){
$i = (strlen($i) < 2)? $i = '0'.$i : $i=$i;
echo '<tr>';
echo '<td>'.$year.''. $month .''.$i.'</td>';
echo '<td><input class="span1" type="number" /></td>';
echo '<td><input class="span1" type="number" /></td>';
echo '<td><input class="btn" type="submit" value="save" /></td>';
echo '</tr>';
}
echo '
</tbody>
</table>';