Welcome to WebmasterWorld Guest from 126.96.36.199
I have a links directory that I would like to count the number of times a link is clicked.
I currently have all the links being displayed by pulling the links data from a MySQL table. I have added the a 'Count' field to the existing table. The table contains the following fields: LinkID, Category, Name, URL, Description, Count.
My question is is it possible to count the clicks once the links data has been printed to HTML? I am thinking of the PHP equivalent of OnClick Count = Count + 1. Or have I got the whole logic back to front?
//Assign the variable
$track = $_GET['track'];
//Get URL from database
$query = "SELECT url FROM table WHERE id = '$track' LIMIT 1") or die(mysql_error());
$row = mysql_fetch_row($query);
mysql_query("UPDATE table SET count=(count+1) WHERE id = '$track' LIMIT 1") or die(mysql_error());
Redirect to URL
Hope that helps.