-3
當我添加if
語句,該語句將存儲在表中的時間值與當前時間進行比較時,PHP將引發錯誤。找不到解決方案。感謝您的幫助。這裏是代碼:在foreach PDO中運行if語句
<?php
//All database times that are 1 hour before stating will be locked in browser not able to reserve any more
$currtime= date("h:i");
foreach ($pdo->query($sql) as $row) {
echo '<tr>';
if ($row['time']-$currtime=<-1) {
echo '<td>'.$row['time']='passed'.'</td>'
};
else {
echo '<td>'. $row['time'] . '</td>';
}
//the following part is just so you know what follows in my code within the loop
if($row[$selected_day]=='available') {
echo '<td>'. '<a href="read.php?id='.$row['id'] . '&s_t_id='.$row['schd_tut_id'].'&dat='.$selected_day .'">available</a>';
} else {
echo '<td>'. $row[$selected_day] . '</td>';
}
}
?>
,如果你向我們展示了誤差會更容易,但可能是這樣的:$ currtime = < - 1那是什麼「? – FLX
';'在'else' - >'}之前; else'。你也無法用這種方式計算時差。 –