
Originally Posted by
Proudirish.com
"when the link is clicked"
How would my script know when the link is clicked? To put it another way, if I put the code to update the count in a text file inside an if statement. What condition should I use for the if statement?
I'm sorry to say that you won't get around using JavaScript for this.
PHP is a server-side language that spits out a load of HTML to be served up by the browser, whereas JavaScript is a client-side language which can dynamically influence the way your user interacts with the page.

Originally Posted by
Proudirish.com
Assuming the link gets a lot of clicks, would using a text file like that be an efficient way to do it, or would it slow down my site?
Nah, probably not.
If you get to the point where you have enough visitors to slow your site by clicking on this link, whether to use a text file or not will be the least of your worries.
---
Edit:
Just thinking out loud, you could code the link like this:
HTML Code:
<a href="linkcounter.php?www.sitepoint.com">Sitepoint</a>
And have linkcounter.php update the count, grab your destination from the query string, then set the header to redirect you to your original goal.
Bookmarks