Page 1 of 1

Need Help Writing Script, For Listing By Views

Posted: Tue Mar 27, 2007 2:14 pm
by morpia
Hello, I have recently started coding in php and I have bought books and searched a million times online and I cannot find out how to list objects according to the amount of times they have been viewed. Can someone help me out with a code here?


Edit: Amount of times viewed either total or daily. Preferably daily. I know how to show it for each individual user, but I want it to be listed as a whole (Everyone that has viewed my site for that entire day.)

Posted: Tue Mar 27, 2007 5:37 pm
by feyd
A database is best suited to storing count information over a number of pages. Only in rare circumstances would it be better to use a file, due to race conditions that may occur.

A views today list will require two fields. The last time it was viewed and the count. When the day changes you will need to reset the count.

Start writing some code and post specific questions you may have.

Posted: Wed Mar 28, 2007 1:26 am
by s.dot
As feyd said, a database count would be best.

Increment the count field by one on every page view. Then when you query for the information out of the database, order it by your count field.