If what u want to do is just to count the number of times a link is clicked and at the same time, redirect she to the destination, the following code might give u an idea.
//get the URL and redirect em to the URL
$sql="SELECT siteURL FROM coolsites WHERE siteId=$id";
$query=query($sql);
$data=fetch($query);
$url=$data['siteURL'];
header("Location:$url");
//add one to the counter
$sql="UPDATE coolsites SET siteVisitCounter=siteVisitCounter+1 WHERE siteId=$id";
$query=query($sql);
Of course, u need to have a database to hold these information.