FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


adding a "this item has been downloaded x times" s





speeDemon
Well, I am thinking about making a gallery page for my website.. and I think that I should add a download feature.. for buttons and movie clips and all...

so I thought that i'll add "this item has been downloaded x times"..

I know very little bit of PHP, I tried learning some time ago.. but I've forgot most of it already!

can someone please give me a script, that can help me out...

I want a script, that can add the value 1 to the variable x, each time the "download me" link is pressed...

hope for some replies! Smile
BillysProgrammer
Have a page that you link to that automatically brings up the download, but when the page loads it will call a function that increases it in a database, example

On Downloads Page You Link To
Code:

<body onload="linktofile.filetype">
<?php
$connection = mysql_connect("localhost", "name", "pass") or die(mysql_error());
mysql_select_db("db_name") or die(mysql_error());
function addDownloadCount() {
    $q = "UPDATE table_name SET download_count +=1";
    $query = mysql_query($q) or die(mysql_error());
}
addDownloadCount();
mysql_close($connection);
?>


Now, theres probably more, and I think I messed up on the UPDATE part, but there is the basic of it.
speeDemon
but I dont really know how to make a database.. Crying or Very sad
Arseniy
You can make a database using cPanel and mySQL functions, just find a function called "new database" Smile
BillysProgrammer
If you have control panel on your website, scroll down till you see a section called "Database" or something similar. On MySQL Databases, click it, a page will come up and there will be a field called Create New Database. Fill it in, and click the button called "Create Database". Once complete, you should already have a user on your Control Panel, if not, create a new MySQL user by scrolling down just a tad.

Once complete, go to Add User to Database. Click the USER dropdown box, and choose the user you want. Then change to the database you want and click "Add".

Than you're all complete Very Happy
sonam
You can try my script it is based on txt file. Idon't know are this script working with images but you can try. Just go on my site and look for Multi Download Counter v.2.1 and if you find useful I can help you with instalation.

Sonam
Related topics
Just Wondering
Online file storage
File Size
HDD and OS Question
Word 2003 problem
MySQL database
Does God exist?
A question
Cron Jobs
Kandy X-Change, Now taking FREE applications from 16+!
You have exceeded the allotted amount of posts and will not
A new website??
Ubuntu 10.04 released! How are you finding it?
Saving a variable in php
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.