I am trying to implement a simple click-counter so I can see how many people I am sending to sites that I have traded links with.

I pulled all of the "friends" out of a DB an sent them to the following page:
$fid = $id;
$ads = mysql_query("SELECT * FROM Ads WHERE $fid=ID");
while ($ad = mysql_fetch_array($ads)) {
	$count = $ad["ClickCount"];
	$URL = $ad["URL"];
	$sql =  "UPDATE Ads SET " .
			"ClickCount='$count' " .
			"WHERE ID=$fid";
	if (!mysql_query($sql)) {
		echo("<p>Error Setting ClickCount: " .
				mysql_error() . "</p>");


<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Refresh" content="5;url=<? echo "$URL"; ?>">

This code works fine, but I've noticed that Hitbox doesn't register that person as being sent from my site. If Hitbox doesn't than I imagine that many others will not either.

Is it possible to write a JS function with the PHP code in it, then call that function in onClick so that when the link is clicked it will run the PHP code without refreshing the page?

BTW, all Friends links are opened in a new window.

- Kurbin

Also, does anyone know of a complete script that does something like this but keeps more detailed stats (such as clicks sent per day, etc).