Jump to content

Download Hit Counter, how to update database on click of url?


Chesso

Recommended Posts

I've been building up a new version of my personal site (building and testing it locally) and I would like to implement a stat showing of how many times a particular file has been downloaded. I already have the database and fetching code done it's just the updating part i'm stuck on.

On my files page up to 5/10 entrys are shown and they are directly linked, I don't have that annoying redirect to 50 other pages thing going on.... So I need to somehow update the download value to increase when they click on a download link.

Any ideas?

P.S. Sorry if this has been answered but because of my idiotic (and quite literally spastic brother) my speed has been capped to dial-up as well as he has the balls to still be playing WoW so searching all through the forum would take a long time.
Link to comment
Share on other sites

Guest footballkid4
Try this:
[code]<?php
//connect to mySQL
mysql_query( "UPDATE downloads SET downloads=downloads+1 WHERE id='" . $_GET['id'] . "'" );
?>[/code]
Then you can use that page to redirect to your download, or even download directly from that page
Link to comment
Share on other sites

Iv'e come across another problem, I can't seem to Update/Replace a record in my table.

Performing the query in phpMyAdmin works perfectly fine, however in my php script it does not.

The code executes and nothing happens, no errors, no warning and other query like reading information work just fine......

Any ideas?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.