如何在单击图像时运行php代码[重复]

Possible Duplicate:
How do I run PHP code when a user clicks on a link?

I have an image .

<image name="" src="">

I have a php code that needs to be run only after the image has been clicked.

<?php

$var = somthing;
if(condition)
{
    sql stmts;
}

?>

like that.

Both are in the same php page. PLease help me to sort out this problem.

Thanks..

You can send a request with javascript. With jQuery that would look like this:

$.get("yourfile.php?function=imageClick", function(data){});

In your php somewhere at the top add:

if($_GET['function'] == 'imageClick'){
  // do your php stuff
}

You can't run PHP code on the client side.

You can do that through an AJAX call: http://www.w3schools.com/ajax/default.asp