jamesjmann Posted February 26, 2011 Share Posted February 26, 2011 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. Quote Link to comment Share on other sites More sharing options...
trq Posted February 26, 2011 Share Posted February 26, 2011 Just my opinion here and it might be a bit of overkill but I would be using Analytics on your site anyway. With Analytics configured you could then use the provided API to display a counter if you want. Quote Link to comment Share on other sites More sharing options...
codefossa Posted February 26, 2011 Share Posted February 26, 2011 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.