Sorry about the dalay and the previous reply wasnt helpful either I was drunk @ the time
I dont have much time at the mo due to work and private life, so I cant write the script for you. I dont have the time to write scripts for my own site at the mo. The best thing to do is buy a basic book on php/mysql. The crux of what you will have to do is to have a database table to store the links in. Instead of linking directly to a file, you will link to a 'redirect' page using a value after the page name. eg redirect.php?value=1
this will take you to a page called redirect.php and the bit after the ? eg value=1 will be separated as a global variable. the script would then look up the value of 1 in a database and get the link, increase a count value by 1, then redirect to the link in question.
I find the best way to get to grips with scripting is to sit down with a book about it and try stuff out.