My site is loading very slowly, it's only a single page that is loading slow, and I suspect it is because of a MySQL query being sent to the database. How can I speed it up?
$depquery = "SELECT * FROM phpvms_schedules
WHERE code = 'FE'
AND locate(dayofweek(convert_tz(now(),'+1:00','+0:00'))-1,".TABLE_PREFIX."schedules.daysofweek)>0
AND phpvms_schedules.enabled = '1'
ORDER BY deptime ASC";
The query is basically working to extract information into a 'Departure Board' table. The table is sorted by deptime
, and it displays results from current time onwards. However, I also want it to go back at least 4 records, to 4 flights before current time.
To clarify, let me give you an example:
It's now 15:25. Because of if(($flight->deptime) >= $time)
and if($count < 15)
and inside a foreach
it will display 15 records on and after that time. However, I want to also travel back 4 records, so it finds last 4 records before 15:25. Is this possible?
Basically, I want to search up and down around the current time.