The mysql is pretty simple. Here's my basic script. It's pretty much the whole thing. Just save it as a php file and then call it with a ?LinkId=XXX parameter
The only thing you would need to set up is a mysql database called linkdb with the following structure:
Once that is done, I just set up a quick form to add/modify an entry, then another page to view the data in a table.
It's not fancy and won't track all these crazy stats like other linking sites, but it will still give you a general idea of which links are being clicked.
$redirection = 'http your site (dot) com; // YOUR URL (I can't post links yet
if($_GET["LinklId"] > 0)
$id = $_GET["LinklId"];
// Connects to your Database
mysql_select_db($database) or die(mysql_error());
//Adds to the click count for a particular link
mysql_query("UPDATE linkdb SET clicks = clicks + 1 WHERE ID = $id")or die(mysql_error());
$data = mysql_query("SELECT redirect_url FROM linkdb WHERE ID = $id") or die(mysql_error());
if(mysql_numrows($data) > 0)
$redirection = mysql_result($data,0,'redirect_url');
//redirects them to the link they clicked
header( "Location: ".$redirection );
It's also probably not coded as efficiently as it could. I am by no means an expert php programmer. I just started reading up on w3school about it about a year ago.