Not sure about php (haven't worked on that)... But we used to do this using java (jsp and servlet).
The concept was -
1) set source of the image as your server file, rather then an image file. Something like -
Code:
<img src="/myserver/recordClickPage.php?param1=value1">
2) on the server, record the click counts and fetch the next image
3) the next image will be returned from the server (by writing it as binary file)
I am not sure how this will work in php. All the best !!!
Regards,
Niral Soni