Jump to content

Recommended Posts

Hey,

 

Im having difficulty storing a top 20 chart based on most sales in descending order.

 

Lets say for simplicity the table was listed with 20 rows and the sales were 1 to 20 in perfect order.

 

But now along comes a new artist who sold 3.

 

So now there is 21 in total so the "1" has to drop off because thats the lowest and it can only show the top 20.

 

So it would then be 2,3,3 ....20.

 

How ever how can i apply this in php so it will always remain having 20 rows in the dabtase.. =/

Link to comment
https://forums.phpfreaks.com/topic/212463-keep-only-top-20/
Share on other sites

How ever how can i apply this in php so it will always remain having 20 rows in the dabtase.. =/

 

at first glance my answer would be the same than Nightslyr's  but your quoted sentence specially the part that say "remain having 20 rows in the database" open the possibility of a different answer...

 

- if you really want to display the highest 20 records from all the existent in your table Nightslyr answer is correct.

- if you want to maintain in your table ONLY the 20 highest records that is a total different problem and solution

 

which one you want?.... EDITED:  just saw your answer

 

Link to comment
https://forums.phpfreaks.com/topic/212463-keep-only-top-20/#findComment-1106936
Share on other sites

I guess I just don't see why you'd want to only keep 20 records in your database. 

 

For one, worrying about db size to that minute detail strikes me as a bit OCD.  Databases are supposed to hold data, and a mere 20 records is a very small sample size.  Also, if your HDD is really that tight, you have other problems to worry about.

 

Two, wouldn't the sales numbers of the least effective people be just as important as the most effective?  And wouldn't it make sense to track these numbers on a monthly basis?

 

To me, your request indicates a llack of time spent planning the database design.  Not trying to be overly harsh, but I think you're painting yourself in a corner, where it will be hard to modify and expand your project because you're locked into an inflexible db design.

 

Just something to think about, IMO.

Link to comment
https://forums.phpfreaks.com/topic/212463-keep-only-top-20/#findComment-1107224
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.