Have a look at Example #1 at http://php.net
Basically, you need to have a script like this in a page, say download.php and then link all your files to be downloaded to this script, say
So, you need to make your download.php a little dynamic to accept the file name from $_GET['file']
and insert into the script.
In that same file, add the code to insert/update into DB to update the counter along with the name of the file.
PS: You need to validate the file name first to prevent people from downloading your "secure" files.