MYSQL Ordering For a Train Timetable PHP Over Midnight -


i trying order sets of train timetables departure times stations problem occurs when train passes on midnight.

below example of data flowing mysql database. given train schedule have basic route , basic departure times each station (marked y under sche). every , may receive update of amended departure times given train schedule.

in self above not problem order data based on timeref. problem comes when train passes midnight. because times receive in pure 24hr format - ie 01:00

count   location       trainid      timeref     sche     update    1      london          t256         22:10        y   2      cricklewood     t256         23:00        y   3      luton           t256         01:00        y    4      leicester       t256         02:00        y   5      doncaster       r659         06:00                 y   6      luton           t256         01:10                 y   7      sheffield       y783         05:00                 y 

i want show data below (in order). ie in order of original timetable updated time luton 01:10

 london        t256      22:10  cricklewood   t256      23:00   luton         t256      01:10  leicester     t256      02:00 

my below code works fine except train crosses midnight

 $stmt3=$mysql_link->prepare("select count,trainid,location,timeref,sche,update (select count,trainid,location,timeref,sche,update darwinall trainid=:trainid order count desc) temp group location order timeref asc");               $stmt3->execute(array(':trainid'=>$trainid));  foreach($stmt3->fetchall(pdo::fetch_assoc) $row3) {  echo result.................  } 

so instead of above following result, wrong

luton         t256      01:10 leicester     t256      02:00 london        t256      22:10 cricklewood   t256      23:00  

if want put times between midnight , 6am after other times, can do:

order timeref < '06:00', timeref 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -