Reply
php click tracker
Old 05-09-2004, 05:59 PM php click tracker
Junior Talker

Posts: 4
I have a simple problem but I have not been able to find any simple solution. All i want to do is display the number of times a song has been downloaded next to the link for the song. I do not want to use a mysql database. Is there any way to do this with text files?
charles degaul is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 05-09-2004, 07:10 PM
Provision's Avatar
Experienced Talker

Posts: 39
Here is a script I made a while back to do counting. Just do the following things:
1. create a file "counter.txt" and type your starting value in it (ex. 0)
2. give the file "counter.txt" read/write permission
3. save the below code to a file (ex. counter.php)
4. include the file where it is needed in your pages (ex. <?php include('counter.php'); ?>
5. Thank me by creating a link to my page or by using Provision Tech when you need a web designer or web host.

PHP Code:
<?php
/////////////////////////////////////////////
////This is a very simple counter
////created by Classic Web Development
////http://www.classicwebdevelopment.com/
////////////////////////////////////////////
if(@$file fopen("counter.txt","r")){
$counter fgets($file);
fclose($file);
$counter++;
$file fopen("counter.txt","w");
fwrite($file$counter);
fclose($file); 
echo 
'Number of Downloads: '.$counter."<br><small>created by <a href=\"http://www.provisiontech.net/\">Provision Tech</a>" ;
}else{
    echo 
'File counter.txt could not be opened or it does not exist.';
    
$file fopen("counter.txt","w");
    
fwrite($file"0");
}
?>
Website Hosting & Design | Classic Web Development

Last edited by Provision : 04-07-2006 at 01:51 AM.
Provision is offline
Reply With Quote
View Public Profile Visit Provision's homepage!
 
Old 05-09-2004, 10:07 PM
Junior Talker

Posts: 4
hmm, this just adds a download every time the page loads. I need it to increase only when the link to the song is clicked. thanks anyway though.
charles degaul is offline
Reply With Quote
View Public Profile
 
Old 05-09-2004, 11:13 PM
WebWishMaster's Avatar
Skilled Talker

Posts: 76
Location: New York City
Quote:
Originally Posted by charles degaul
hmm, this just adds a download every time the page loads. I need it to increase only when the link to the song is clicked. thanks anyway though.
if you're not in a hurry I could do something for you on wednesday.. I'm really booked up mon and tues so that's the earliest I can help you out.

let me know if you're still interested by then. Best bet is to icq me #67279431
WebWishMaster is offline
Reply With Quote
View Public Profile Visit WebWishMaster's homepage!
 
Old 05-10-2004, 02:42 AM
Provision's Avatar
Experienced Talker

Posts: 39
Quote:
this just adds a download every time the page loads.
Sorry about that for some reason I was thinking you needed a basic counter.

ok, to make up for my mistake I've written another script, which should be right this time.

Just download the attachment and take a look at the README.txt file for directions.

Let me know if you have any problems.

Website Hosting & Design | Classic Web Development
Attached Files
File Type: zip downloadCounter.zip (1.6 KB, 10 views)

Last edited by Provision : 04-07-2006 at 01:52 AM.
Provision is offline
Reply With Quote
View Public Profile Visit Provision's homepage!
 
Reply     « Reply to php click tracker
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.35470 seconds with 14 queries