|
-
Dec 4th, 2002, 08:07 PM
#1
Thread Starter
Fanatic Member
Count the Clicks
How do I keep track of and record the # of clicks on a certain link?
thanks
-
Dec 4th, 2002, 11:27 PM
#2
Stuck in the 80s
The easiest way would be to use a MySQL database over flat file.
Have your link like this: http://www.site.com/tracker.php?link....com/about.php
Then do something like:
Code:
mysql_connect(...);
$results = mysql_query("SELECT ... WHERE sitename='" . $_REQUEST['link'] . "'");
if ($result = mysql_fetch_array($results)) {
//exists in database already. update:
$count = $result['hits'] + 1;
mysql_query("UPDATE ... SET hits='$count' WHERE ...");
} else {
//does not exist. add new entry:
myql_query("INSERT ... (site, hits) VALUES ('" . $_REQUEST['link'] . "', '1'");
}
header("Location: " . $_REQUEST['link']);
Something along those lines. Note that that's all psuedocode off the top of my head and wont automatically work. You need to create the table and fill in a few blanks.
Hope this helps.
-
Dec 5th, 2002, 11:45 AM
#3
Thread Starter
Fanatic Member
alright i get the basic idea, thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|