Accurax Posted March 5, 2007 Share Posted March 5, 2007 I have a number of members stored in my database, and i would like to create a page to allow people to browse through the members and see certian bits of information. I would like this page to be dynamically ordered (sorted) by the date the information was last updated, thereby keeping the most up to date information at the front, and penalising those that dont update often. I am thinking of simply adding a field in my database, and inserting a gregorian timestamp (based on the servers current date) everytime a member updates the info. Firstly, is this the best way of keeping track of updates ? And, how would i go about ordering my data by this particular data?..... does php have an "order by" function? Link to comment https://forums.phpfreaks.com/topic/41265-sorting-data-whats-the-best-way/ Share on other sites More sharing options...
benjaminbeazy Posted March 5, 2007 Share Posted March 5, 2007 mysql_query("SELECT * from members ORDER BY last_updated DESC"); that is if you make a field last_updated with a unix timestamp Link to comment https://forums.phpfreaks.com/topic/41265-sorting-data-whats-the-best-way/#findComment-199925 Share on other sites More sharing options...
Accurax Posted March 5, 2007 Author Share Posted March 5, 2007 Thats exactly what i was looking for thankyou. Link to comment https://forums.phpfreaks.com/topic/41265-sorting-data-whats-the-best-way/#findComment-199928 Share on other sites More sharing options...
benjaminbeazy Posted March 5, 2007 Share Posted March 5, 2007 no problemo Link to comment https://forums.phpfreaks.com/topic/41265-sorting-data-whats-the-best-way/#findComment-199931 Share on other sites More sharing options...
php_joe Posted March 5, 2007 Share Posted March 5, 2007 If you're storing your info as lines in a text file instead of a mysql database, you could do what you said and add a field to the front of each line, getting the info for field with time(). Then, before you write to the file, use sort() or arsort() to sort the info. Joe Link to comment https://forums.phpfreaks.com/topic/41265-sorting-data-whats-the-best-way/#findComment-199932 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.