Need a solution to display random images depending of the hour.
My database contains 2 columns:
start_time
end_time
with hour ranges from each image (only hours, not minutes):
15 | 18
9 | 13
21 | 7
I tried it in this way:
$timenow = date("H");
$result = mysql_query("SELECT id FROM images_rotate
where start_time < $timenow and end_time > $timenow
ORDER BY last_showed ASC limit 0, 1") or die(mysql_error());
It works but there is a problem when start time number is biger than end time number after midnight. For example, if I want to display an image from 21:00 in the evening till 06:00 in the morning, the start time will be 21 and time 6, so the image will be not displayed using this query.
Any ideas how to solve this problem?
Thanks