tags:

views:

100

answers:

3

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 )

A: 

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.
I planned to do it, but it's pretty easy to make fake downloads. Thanks anyway...
Filip
A: 

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

Wrikken
A: 

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

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

Unreason
Thanks... ( I don't have rights to vote this up :) )
Filip
No problem, just accept it :D (and come back later :D )
Unreason
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