Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Script to track and display number of link clicks
Old 02-07-2009, 04:28 PM Script to track and display number of link clicks
Skilled Talker

Posts: 90
Trades: 0
Does anyone know of a script or have a script that track the number of times a link is clicked and then display it. Like http://flashmo.com does.

Thanks
__________________
Free Flash designs and tutorials at
Please login or register to view this content. Registration is FREE

Shorten your URL's with
Please login or register to view this content. Registration is FREE
xuroq is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-07-2009, 05:23 PM Re: Script to track and display number of link clicks
rogem002's Avatar
PHP Chap

Posts: 843
Name: Mike
Location: United Kingdom
Trades: 0
Yes.

PHP Code:
<?php
$ID 
$_GET[ID];
$current_clicks file_get_contets($ID.'clicks.htm');

$current_clicks++;

file_put_contents($current_clicks$ID.'clicks.htm');
?>
then just format all the URL's with a specific ID like
file.php?ID=2

To find out how many clicks, just use
PHP Code:
<?php
$ID 
"2"// set this as something like 2.
echo file_get_contets($ID.'clicks.htm');
?>
Very simple, but seems to meet your requirements.
__________________
My Blog/Site:
Please login or register to view this content. Registration is FREE

Last edited by rogem002; 02-07-2009 at 05:25 PM..
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 02-07-2009, 08:11 PM Re: Script to track and display number of link clicks
Skilled Talker

Posts: 90
Trades: 0
This is not working for me. I have corrected the spelling mistake of contents, but I do not see how the script works all it seems do do is create a file called '1'
__________________
Free Flash designs and tutorials at
Please login or register to view this content. Registration is FREE

Shorten your URL's with
Please login or register to view this content. Registration is FREE
xuroq is offline
Reply With Quote
View Public Profile
 
Old 02-07-2009, 09:31 PM Re: Script to track and display number of link clicks
Decaf's Avatar
Ultra Talker

Posts: 489
Name: Adam
Trades: 0
Just have the "ccount/click.php?id={ID}" script write to a mysql DB when the link is clicked.

Or you could have it increment the amount of "clicks" on a specific link, by querying the amount before, adding one and then replacing the old amount.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Decaf is offline
Reply With Quote
View Public Profile Visit Decaf's homepage!
 
Old 02-08-2009, 07:52 AM Re: Script to track and display number of link clicks
Skilled Talker

Posts: 90
Trades: 0
I have looked at Ccount but unfortunately i do not have a database to write to. I was more looking for a piece of code that simply writes to a txt file when the page is displayed, and then a piece of code that will grab that info and display it
__________________
Free Flash designs and tutorials at
Please login or register to view this content. Registration is FREE

Shorten your URL's with
Please login or register to view this content. Registration is FREE
xuroq is offline
Reply With Quote
View Public Profile
 
Old 02-08-2009, 01:24 PM Re: Script to track and display number of link clicks
Decaf's Avatar
Ultra Talker

Posts: 489
Name: Adam
Trades: 0
Quote:
Originally Posted by xuroq View Post
I have looked at Ccount but unfortunately i do not have a database to write to. I was more looking for a piece of code that simply writes to a txt file when the page is displayed, and then a piece of code that will grab that info and display it
Then why not write to a file with the link id followed by a comma.

PHP Code:
<?php
$id 
$_GET['id'];

if (isset(
$id)) {
     
$file fopen("linkCount.txt","w");
     
fwrite($file,"$id, ");
     
fclose($file);
} else {
     print 
"Error";
}
?>
Something like that, you may want to check against all of the possible links to avoid "$id" spam. You should also store IP's to prevent people trying to inflate the link count. Also, if your looking for a mysql DB, pm me.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE


Last edited by Decaf; 02-08-2009 at 06:48 PM..
Decaf is offline
Reply With Quote
View Public Profile Visit Decaf's homepage!
 
Old 02-08-2009, 03:51 PM Re: Script to track and display number of link clicks
Skilled Talker

Posts: 90
Trades: 0
sorry this script is not working. Nothing is written to the file
__________________
Free Flash designs and tutorials at
Please login or register to view this content. Registration is FREE

Shorten your URL's with
Please login or register to view this content. Registration is FREE
xuroq is offline
Reply With Quote
View Public Profile
 
Old 02-08-2009, 04:13 PM Re: Script to track and display number of link clicks
rogem002's Avatar
PHP Chap

Posts: 843
Name: Mike
Location: United Kingdom
Trades: 0
In that case the file is not writeable. You should hire a programmer to take a look at your backend.
__________________
My Blog/Site:
Please login or register to view this content. Registration is FREE

Last edited by rogem002; 02-08-2009 at 05:02 PM..
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 02-08-2009, 06:48 PM Re: Script to track and display number of link clicks
Decaf's Avatar
Ultra Talker

Posts: 489
Name: Adam
Trades: 0
Quote:
Originally Posted by xuroq View Post
sorry this script is not working. Nothing is written to the file
My bad, I had an extra set of quotes.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Decaf is offline
Reply With Quote
View Public Profile Visit Decaf's homepage!
 
Reply     « Reply to Script to track and display number of link clicks
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB 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.36997 seconds with 12 queries