Jump to content

monitoring downloads


Ltj_bukem

Recommended Posts

Hi,

 

I've got a site in which users can download pdf's & wavs, all of the code works fine but I'd like to add features

to monitor what information is being downloaded from the site. I have a database with three tables, user, pdf & wav. Is there

a simple query to find out, say, the top ten downloaded wavs? I am sure there is but I am fairly new to this, I imagine I'd

have to track each downloaded file somehow.

 

If anyone has any ideas to point me in the right direction Id be very grateful.

 

LTJ

Link to comment
Share on other sites

am not a php guru but i wouldent make a direct link to the file but to a another script ex. download?filename=myfile.exe and on that page you could have run a query wich updates the colum wich contains information about myfile.exe like downloads_num, last_download etc, after the query is complite then just call up the file so the user can download it.... i hop this helps

Link to comment
Share on other sites

Basically in the database you'll have:

fileId

fileName

fileLocation

etc...

 

then when they go to download something, rather than site.com/file.pfd it'll be site.com/download.php?file=338 (where 338 is a file Id).  Then on download.php you just run a simple query to update a column in your users table with what file id they downloaded.  This column can contain all of the files they've downloaded in just one field, like 007-332-13-113-553, then just use explode() when your script calls for their download history.  Hope it makes sense, I'm not the best at explaining things. 

Link to comment
Share on other sites

what you would have to do is create a extra table which will keep the counts for each download.

in that table have the table id, the pdf id wav id, counter, and date..

 

you can basically doit 2 ways either update the same id with the counter, or just keep adding tot he table each time the file is downloaded and keep it by date.

 

when someone click on download.php?filename=$thisfile&id=fileid&type

 

the query would look something like this.

 

INSERT INTO downloaded_file(id,wavid,pdfid,count,date)values(...)

 

if the file exist and you want to update the counter just use.

 

UPDATE downloaded_file SET counter=+1 WHERE wav or pdf id = id

 

 

i tried to explain both ways at the same time you can just simplify it and then work your way up.

Link to comment
Share on other sites

Right, I've got a table which updates a transaction_id(auto_increment), the pdf_id, count and date. Now, when a user downloads a pdf

the table is updated, this works well except that I would like the count to be updated for every record of that pdf_id.

 

For example, if I downloaded the same pdf three times this is what I would get;

 

tr_id    id      count     date

1 1     3     2007-11-28

2 1     2     2007-11-28

3 1     1     2007-11-28

 

when what I really need is the count to updated for all versions up that pdf_id

 

tr_id    id    count date

1 1     3     2007-11-28

2 1     3     2007-11-28

3 1     3     2007-11-28

 

Here's the query...

 

   

$today = date("y.m.d");
$query = "INSERT INTO pdf_count VALUES ('','$id','', '$today')";

    mysql_query($query) or die('Error, query failed : ' . mysql_error());
   

	 	  $query =" UPDATE pdf_count SET count=count+1 WHERE id = id";

  

 

Any thoughts..?

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.