The simplest way is to create a script that takes an URL as an argument so you can call it like this:
<a href=www.yourserver.bla/redirect_script.php?url=www.somewhereelese.com>Click here</a>
When the user clicks the link, the redirect script
updates the database (inserts a record into it containing the URL, or updates a counter for an existing URL) and uses the header() command to redirect the user to the real URL:
header("Location: www.somewhereelse.com");
Note: you may have to play around with URLENCODE() to get the url in the link correctly. For example, if there is a questionmark in the url you are trying to pass along, the browser might think the question mark belongs to the current link, not to what you want to pass along.