电视指南脚本 - 获取当前日期节目

时间:2010-05-17 18:25:32

标签: php sql mysql apache

这是我的电视指南脚本的一部分:

       //Connect to the database
   mysql_connect("localhost","root","PASSWORD");
   //Select DB
   mysql_select_db("mytvguide");

   //Select only results for today and future
   $result = mysql_query("SELECT programme, channel, episode, airdate, expiration, setreminder FROM mediumonair where airdate >= now()");

剧集出现了,所以那里没有问题。但是,它正在让数据库找到问题所在的数据。

如果我为今天播放的节目添加记录,则应显示:

Medium   showing on TV4   8:30pm    "Episode"    Set Reminder
Medium  showing on TV4  May 18th - 6:25pm  "Episode 2"  Set Reminder
Medium  showing on TV4  May 18th - 10:25pm  "Episode 3"  Set Reminder
Medium  showing on TV4  May 19th - 7:30pm  "Episode 3"  Set Reminder
Medium  showing on TV4  May 20th - 1:25am  "Episode 3"  Set Reminder
Medium  showing on TV4  May 20th - 6:25pm  "Episode 4"  Set Reminder

但是这反过来显示:

    Medium  showing on TV4  May 18th - 6:25pm  "Episode 2"  Set Reminder
Medium  showing on TV4  May 18th - 10:25pm  "Episode 3"  Set Reminder
Medium  showing on TV4  May 19th - 7:30pm  "Episode 3"  Set Reminder
Medium  showing on TV4  May 20th - 1:25am  "Episode 3"  Set Reminder
Medium  showing on TV4  May 20th - 6:25pm  "Episode 4"  Set Reminder

我几乎让SQL工作;只是不确定这里有什么正确的代码,以避免第二个错误显示 - 因为记录(表示正在播出的节目)目前似乎不起作用。

请有人帮我这个吗?

由于

1 个答案:

答案 0 :(得分:0)

我不知道,但我猜你在日期和时间中存储日期和时间的方式有些奇怪。尝试运行这样的查询,这样您就可以进行与数据库要求相同的比较:

select now(), airdate from mediumonair where episode = 'Episode'