I want to make a picture send a specific value tied to that image when clicked to a php file that will make a mySQL query.
For example let say I have a HTML page of animal pictures that when a specific animal image is clicked, say an image of a Cat, it would sent that as a value to be assigned to a variable that is then put into a MySQL query that will pull out different breeds of cats from an animal database containing cats,dogs, horses, ect.
So in the HTML page, animals.html, I am creating the images with this code:
//animals.html
<form action="animalQuery.php" method="get"> <input type="image" src="Cat.jpg" name="cats" width="350" height="225">
<form action="animalQuery.php" method="get"> <input type="image" src="Dog.jpg" name="dogs" width="350" height="225">
When the Cat.jpg image is clicked I want to send the value “cats” to be assigned to $animal variable so that it basically makes the $stmt below equate to “select * from Animals where breeds = ‘cats’;” which is a working Query.
//animalQuery.php
$animal=$_GET["cats"];
$stmt="select * from Animals where breeds = $animal;";
It works if I hard code the $stmt with value of “cats” or “dogs” in place of the variable $animal, so I know the Query works. I am just having trouble figuring out how to have the image when clicked send the specific value I want to that variable $animal. Once I figure that out I should be able to figure out how to have the single variable $animal get set to a certain value when one of the many images is clicked so that one variable works for all the images.
Why a full-blown form for something so simple?