Jump to content


Photo

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


  • Please log in to reply
2 replies to this topic

#1 Chesso

Chesso
  • Members
  • PipPip
  • Member
  • 27 posts

Posted 30 March 2006 - 02:19 PM

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.

#2 Guest_footballkid4_*

Guest_footballkid4_*
  • Guests

Posted 30 March 2006 - 02:21 PM

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

#3 Chesso

Chesso
  • Members
  • PipPip
  • Member
  • 27 posts

Posted 31 March 2006 - 02:11 PM

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?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users