I had an image created by using PHP code in which the x and y values in the code interpret the points on the image. I would like to perform mouse click event on that image such that any click on that image who add an point to that and should store in the database. Is it possible? If possible which method should I use? Can you describe?
Here goes my php image creation code:
<?php
include('ag_fetching.php');
header("Content-type: image/png");
$image = imagecreatetruecolor(800, 800);
$red = imagecolorallocate($image, 250, 0, 0);
for($i=0;$i<$count;$i++)
{
imagefilledellipse($image, $a[$i], $b[$i], 10, 10, $red);
}
imagepng($image,'ag_graph.png');
?>
Here $a[$i],$b[$i] are arrays stored with X an Y coordinates of points to be created on image and are stored in database.So ,inclusion of "ag_fetching.php" file is for that purpose.
Using the code above I create an image with background color as black and points on that as red. Can I add points by mouse clicks such that points are to be recorded in a desired database?
I can do it with three files :
Next three files work like a charm, you just create three files with the same names, copy-paste next codes in the files and open coords.php in your browser :
coords.php
coords_img.php
coords_db.php
In my example codes I use two $_SESSION variables to simulate the database :
$_SESSION["arr_x"]
and$_SESSION["arr_y"]
, they work fine. To make it work with a real database you will have to remove the two $_SESSION variables from the three files, then you add a connection to database and a "insert" query in coords_db.php, finally, you add another connection to database and a "select" query in coords_img.php.