thinking on the fly here, you often see websites where links are like
say the homepage of originsite is
http://www.eightseven.net/
then the link will actually be on your own site
so like the "google link here" would be http://www.eightseven.net/redirect.php?linkid=1
when the page redirect.php is loaded
use $_GET=['linkid'] (in this case 1) to get the id of the link. Write a function that can look up the real link from a MySQL database. This function can increment a counter, insert/update the link table, and then re-driect to google. the re-direct can be done either using php's header() of html's redirect.