1
deka87
How do I know the most popular entry today using counter
  • 2011/12/1 10:57

  • deka87

  • Friend of XOOPS

  • Posts: 1125

  • Since: 2007/10/5


I have a lexikon module installed with lots of entries there. Each entry has a counter to calculate how many times it was shown on the user side.

$xoopsDB -> queryF"UPDATE " $xoopsDB -> prefix"lxentries" ) . " SET counter = counter+1 WHERE term = '$term' " );


I want to create a 'Word of the day' block to show the most popular entry today (the entry that was shown the most times for the latest 24 hours). Any ideas how to do this?

Regards,

Deka
Mind anchors

2
wishcraft
Re: How do I know the most popular entry today using counter

Hi deka,

You need to create a table that counts the id of the word and the unix timestamp of the hit. Then you also need to drop the table records when the unixtimestamp is more than 48 hours old otherwise you will end up with a huge table.

Once you have done that you need to do a select a bit like:

SELECT COUNT(*) as `rc`, `idFROM `TABLE_NAME`WHERE timestamp 13000000 ORDER BY RC DESC LIMIT 0,1


This will return the number of hits it has from largest to smallest with the id of the item. 13000000 has to equal 24 hours ago in unixtime which would be something like:

$time time() - 60*60*24;
Resized Image
http://www.ohloh.net/accounts/226400

Follow, Like & Read:-

twitter.com/RegaltyFamily
github.com/Chronolabs-Cooperative
facebook.com/DrAntonyRoberts

3
deka87
Re: How do I know the most popular entry today using counter
  • 2011/12/2 9:34

  • deka87

  • Friend of XOOPS

  • Posts: 1125

  • Since: 2007/10/5


thanks wishcraft. i believe this will work
Mind anchors

Login

Who's Online

338 user(s) are online (201 user(s) are browsing Support Forums)


Members: 0


Guests: 338


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits