Very simply put ajax just allows you to run a script in the background and grap the results. For example.
//file names here are just for example you can call them anything you want
lets say your running a php file we will call it file1.php
and in that file you call ajax to run file2.php
Lets say that in file2.php (the ajax called file) it outputs "HELLO" to the page. Using an ajax routine allows
you to grab that output of "HELLO" and use that result in your file1.php without having to leave your file1.php.
Hope that helps. Let me see what i can see here, im not a pro by any means but i will see what i can see here.
Ok i took a look and it seems to me your making this way to complicated, if you just want to increment the number of clicks to whatever they click on then keep it simple.
The user logs in.
The user is taken to a page with lets say 3 images image1.jpg image2.jpg image3.jpg
And lets say you have a table named imageclicks and in that table you have three fields set as INT clicks_img1 clicks_img2 clicks_img3
Then instead of clicking on the image itself maybe click on the submit button below it.
In your form you could have submit button, one form under each image.
Or you could set up a radio button display where you can have the same name attributes,
but lets keep this simple for ya. I did it this way to help your wrap your brain around the process is all.
Code:
<form method="post" action="whatever file" name="imgFrm1" >
<input type="hidden" name="img1" value="1" />
<input type="submit" name="submit1" value="submit" />
</form>
<form method="post" action="whatever file" name="imgFrm2" >
<input type="hidden" name="img2" value="2" />
<input type="submit" name="submit2" value="submit" />
</form>
<form method="post" action="whatever file" name="imgFrm3" >
<input type="hidden" name="img3" value="3" />
<input type="submit" name="submit3" value="submit" />
</form>
Now which ever submit button they click on will send that value in the post value.
So now we check the post value
PHP Code:
<?php
if($_POST['img1'])
{
$theyclicked = "clicks_img1"; //this is the name of table field we are gonna use it in the query
}elseif($_POST['img2'])
{
$theyclicked = "clicks_img2"; //this is the name of table field we are gonna use it in the query
}else{
if($_POST['img3'])
{
$theyclicked = "clicks_img3"; //this is the name of table field we are gonna use it in the query
}
}//close else
//then just do your query because now you know which one they clicked and you can add to that value.
$query = "UPDATE imageclicks SET $theyclicked = $theyclicked +1";
//then when you need it just grab the value from the table.
?>
This is not tested but hope it helps you with your project. And there are fancier more elaberate ways of doing this but as i said i just wanted to keep it simple so you could follow the process, then once you get the process in your head you can attack it in a more elaberate way using javascript or ajax or different form attributes.