开发者

TV Guide script - getting current date programmes to show

This is part of my TV guide script:

       //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()");

The episodes show up, so there are no issues there. However, it's getting the database to find data that's the issue.

If I add a record for a programme that airs today this should show:

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

but this shows instead:

    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

I almost have the SQL working; just not sure what the right code is here, to avoid the second mistake showing - as the record (which indicates a show currently airing) does not seem to work at present.

Please can anyone help me with this?

Thanks


I don't know, but I would guess there's something strange about the way that you are storing your date and time in the airdate column. Try running a query like this so you can do the same comparison you're asking the database to do:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜