Re: Most popular per month

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Jul 11, 2008, at 555PM, Ryan S wrote:
before the next days counter starts this data is stored in a table which has a simple structure like this
img_id1 int,img_id2 int  (etc till img_id10)

That sounds like a painful db structure to deal with if you want to add more images in the future. I'd suggest a structure more like:

img_id
date_viewed
counter

Where counter is simply the number of times the specified image was viewed on that day. I just finished writing a blog post about a similar requirement that may help - http://bradym.net/mysql/logging-requests-with-mysql .

Now the client wants a little extra functionality, and with me sucking at maths I need some help please, basically he now wants to have a chart with all the 50 images there and showing _via percentages_ instead of the present 1-10 display which ones are the most popular till date.

You get the percentage simply by dividing the number of requests for a specific image by the total number of requests for all images. So if you had the following data:

img1 - 50 views
img2 - 20 views
img3 - 15 views
img4 - 10 views
img5 - 5 views

To get the total, you would just add all those views together (100) in this case. Then for the percentages just divide each one by 100, ie: $img1_percent = 50 / 100;

Also, if i am not mistaken there was some charting software to display this kind of data in pie and line charts... anybody know what i am talking about? because i cant find such a link in my bookmarks.

There are several options for charting, here's a post I came across earlier in the week with some options: http://free-wiz.blogspot.com/2008/07/best-free-chart-apis.html .

Brady

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux