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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.