No worries
Yes, it's possible to have the database update when someone clicks on the image.
- My personal preference would probably be an AJAX call (using Prototype) to POST some data to a PHP page which can run server-side code to update the database. After that ajax call, you can then redirect to user to wherever the image link goes to.
- The other method would be to create a 'bounce page', whereby it'd work like this:
1. Adjust the code that 'echoes' out the image to change the link to 'www.YOURSITE.com/bounce.php?id=6' - where the link always refers to your 'bounce page', and it also builds a query string with the images' ID.
2. Create a bounce page that will read in the ID passed to it, then read from the database the image relating to that ID, as well as the link that the user should be forwarded to.
3. Update the record in the database, also based on the ID sent by the previous page.
4. Then redirect the user to the page you obtained in step 2.
Hope that makes sense!
Ed.