0

Which is the most simple way to create code ( with PHP and SQL ) which will count the file downloads ?

I already have an integer column in the base dedicated for this feature...

( link to some example will also be welcomed )

Filip
  • 15
  • 2
  • 4
  • possible duplicate of [Best way to count file downloads on a website](http://stackoverflow.com/questions/158124/best-way-to-count-file-downloads-on-a-website) and [Best way to implement a download counter?](http://stackoverflow.com/questions/441618/best-way-to-implement-a-download-counter) – Gordon Jun 08 '10 at 13:06

3 Answers3

0

Create an sql table with two columns:

  1. Full path to file (primary key)
  2. Counter

Setup your links for downloading to go to a php script. In that script, lookup the appropriate table row based on the full path, increment it's count, then redirect the browser to the file for downloading.

Doug T.
  • 64,223
  • 27
  • 138
  • 202
0

You can make a download script, which is very bad for performance. My solution would be just periodical apache access log parsing.

Wrikken
  • 69,272
  • 8
  • 97
  • 136
0

http://tutorialzine.com/2010/02/php-mysql-download-counter/

(2nd on google search results with keywords: php mysql create download counter)

Unreason
  • 12,556
  • 2
  • 34
  • 50
  • But this is a little complicated for me :(. I'll go with the Doug's suggestion. Maybe in few months I'll update it... – Filip Jun 08 '10 at 14:02