Jump to content

Algorithm to order my records


adambedford

Recommended Posts

I'm writing a script where I need to order my results based on two things: the number of hits they receive, and the date the record was created.

 

Ideally, I want the most popular records at the top (or do I, I'm not sure of this yet!) but I also need newly created records to have a chance of receiving hits (ie. if they are new and don't have any hits, I don't want them to be at the bottom from the get-go and not have a chance of being seen.)

 

My hits are recorded in a separate table and the 'date created' field is in the main table.

 

Does anyone have any idea as to how I can organise these records to that the new ones get a fair chance of getting clicked. I also want to avoid the situation where the most popular ones remain at the top and don't allow the others a chance to get clicked. I don't want these records to spiral out of control with regards to hits.

 

I'm relatively new to PHP and I don't really have a clue where to start with this.

 

Any help would be greatly appreciated.

Link to comment
https://forums.phpfreaks.com/topic/191359-algorithm-to-order-my-records/
Share on other sites

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.