PHP从数据库中选择all并与day calendar进行比较
我为当前月份创建了一个日历,但我还需要检查数据库中是否存在具有相同月份和年份的行。并且如果在当天的工作时间行中显示一个。这是我的密码PHP从数据库中选择all并与day calendar进行比较,php,mysql,select,for-loop,pdo,Php,Mysql,Select,For Loop,Pdo,我为当前月份创建了一个日历,但我还需要检查数据库中是否存在具有相同月份和年份的行。并且如果在当天的工作时间行中显示一个。这是我的密码 echo ' <table class="table table-hover"> <thead> <tr> <th>Date</th>
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>';
你们有什么问题吗?把一天,一小时,一个月,一年分别放在不同的栏目里真是件坏事