Jump to content

Sorting data - Whats the best way?


Accurax

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.