events timetable

Joshie

WebHost Founder
May 29, 2015
143
20
how do I like make it in order by time so it shows
12
1
2
3

instead of
12
4
13
17
 

JayC

Always Learning
Aug 8, 2013
5,493
1,398
If the events are fetched from database use the 'ORDER BY' function.
You will want to do either:

SELECT * FROM events ORDER BY timestamp ASC
Which makes the outcome this:
2
5
7
OR
SELECT * FROM events ORDER BY timestamp DESC
Which makes the outcome this:
7
5
2

Make sure you add "LIMIT 10" or however many you want at the end of the statement:
SELECT * FROM events ORDER BY timestamp DESC LIMIT 10
and if you would like to keep track of all your events that are active/past events then have a column in the events table like "active" and do this:
active int 11 0 NOT NULL default 1

SELECT * FROM events WHERE `active` = '1' ORDER BY timestamp DESC LIMIT 1
 

Users who are viewing this thread

Top