You need to build a re-director script that takes in the final destination as a parameter and logs it before pushing the user to the page that was requested.
So you'd build your links to look something like this:
http://www.mysite.com/redirector.php?url=http://www.mysite.com/result5.php
Or something similar then in the redirector script you'd get whats in the $url variable and store it in the database then use the header() function to push the user to the page requested.