我有以下PHP脚本:
$day = date("N");
$query_board = "SELECT day, time, timefromto, type, event, title, location, description, `until`, endtime FROM schedule WHERE `until` >= '$server_time' AND day LIKE '%$day%' ORDER BY `time` ASC";
这在whatsondv.co.uk显示如此:
我想创建另一个页面,显示第二天(即明天)的结果。因此,如果当天为2
(星期二),那么3
只会出现day
的结果。
这是否需要更改$day
或其他内容的定义?
答案 0 :(得分:0)
您可以使用准备好的声明:
$pdo = new PDO('mysql:dbname=' . $database . ';host=' . $host, $user, $password);
$query = $pdo->prepare('SELECT day, time, timefromto, type, event, title, location, description, `until`, endtime FROM schedule WHERE `until` >= :server_time AND day LIKE :day ORDER BY `time` ASC')
$query->execute(
array(
':server_time' => $server_time,
':day' => $day
)
);
答案 1 :(得分:0)
更简单的方法:添加另一列列出' day'值减1(或在7的情况下,返回1)。然后使用:
$day = date("N");
$query_board = "SELECT tmrw, time, timefromto, type, event, title, location, description, `until`, endtime FROM schedule WHERE `until` >= '$server_time' AND tmrw LIKE '%$day%' ORDER BY `time` ASC";
这很有效。