hi, i just want to know how can i keep the amount of downloades files in my website. i have a mysql database with a field named count which have the amount of times a program or file has been downloaded. but i want to know how can i increase that variable so everytime a program or document is downloaded appears the total downloaded times of that particular program or document. i will apreciate any help thanks
Announcement
Collapse
No announcement yet.
downloaded files question
Collapse
X
-
Something like
update table set yourcountvariable = yourcountvariable + 1Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html
-
Just link the user to a php script on downloading.
This php scripts sets its mime-header as the file type the user want to download, opens the file and outputs it.
And before opening the file you're able to execute every code you want.
Alternatively, you can link to a php script, execute your counting code and if this is done, just redirect with header(...) to the download file.
greetz
Paul
Comment
-
mmmmmmmm i dont understand too well the mime-header thing.
can someone write a code to have an idea?
i just want that when a user download a file, in the right column of my table the download amount increase by one. so when a person enter my website can see how many times a specific program has been downloaded. thanks for your help i appreciate it.
Comment
-
PHP Code:<?php
// place here your code to count the downloads, for example:
$conn = @mysql_connect("localhost", "user", "pw");
@mysql_select_db("database", $conn);
@mysql_query("UPDATE downloadConterTable SET downloads = downloads + 1");
// Setting MIME-type, for example a zip
header('Content-type: application/zip');
// Setting Name of download
header('Content-Disposition: attachment; filename="download.zip"');
// ouput file content
readfile('original_file.zip');
?>
...and consider there is a bug in older IEs.
Comment
Comment