Jump to content

Download Counter


jamesjmann

Recommended Posts

I have music (my own) that I want to put on my website for download, and I was wondering if there is a way to keep track of how many people download each song, by tracking the clicks and displaying that number in a css-styled box. Anyone know how this is done? I don't need help with the css, just the php.

Link to comment
https://forums.phpfreaks.com/topic/228875-download-counter/
Share on other sites

Use AJAX to post it to another page, and JQuery to prevent it from refreshing.  Also, inside of the JQuery you can direct it to the download, so you will do both in one.  You just need to set a query function in that PHP page to handle the variables and update the database column by +1 for the correct row given by the post variables.

 

If you  need more help, just ask and I can post some code after my TV show is over.

 

A second idea without Javascript would be to just add a PHP page that you direct to with GET variables to set which row to update.  Then you have that page redirect with a header refresh, they won't know the difference between that and a direct link, and you'll get the results you want.

 

I'd go with the second idea.

Link to comment
https://forums.phpfreaks.com/topic/228875-download-counter/#findComment-1179905
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.