<?
$url = $_SERVER['REQUEST_URI'];
$a123 = explode("?url=", $url);
$url = $a123[1];
$date = date("d/m/y"); // Grabs date
/* MYSQL CONNECT */
$db_host = "localhost";
$db_username = "username"; // Will most likely need your username as a prefix
$db_password = "password";
$db_name = "database"; // Will most likely need your username as a prefix
mysql_connect($db_host,$db_username,$db_password) or die(mysql_error()); // This just connects to your server, will give an error message if it cant
mysql_select_db($db_name) or die(mysql_error()); // This selects the database to work on, this will give an error if it cant aswell
$query = "SELECT * FROM clicks WHERE url='$url'"; // Query to find the url if it already exists
$result = mysql_query($query);
while($r=mysql_fetch_array($result))
{
$clicks = "$r[clicks]";
$clicks++; // Adds one click to the total clicks
$end = "okay"; // This just tells the script that the url already exists and doesnt need to add a new entry
$query = "UPDATE `clicks` SET `date` = '$date', `clicks` = '$clicks' WHERE `id` = '$r[id]' LIMIT 1"; // Query to add a click to the url
mysql_query($query); // Add one more click to the url
}
if ($end != okay) { // If the url isnt already in the databse run the following lines
$query = "INSERT INTO clicks (url, clicks, date)
VALUES ('$url','1','$date')"; // Adds the url to the databse to start recoding clicks
mysql_query($query);
}
header("Location: $url"); // Go To the link that you clicked on
// For a tutorial on displaying the clicks with a nice per page system please ask me to add it :o
?>
i need some hep with this script from http://zulumonkey.org. How would i display how many times the link was clicked on my site.
Edited by markc1822, 24 January 2007 - 08:12 PM.
