3
votes

I am developing a website where I have come across a problem. The thing is, the user has to select one image out of the 3 images that I am displaying. How to capture that click and store that particular clicked image in the database? My sql is the dB.

Thanks in advance

2
What have you tried? It seems pretty simple - capture it with JS and send an Ajax request to store it server-side.jeremyharris
You cannot capture a mouse click in php, as php runs serverside, not client side, php doesn't know what a mouse is. You'd need to provide some more details on what you've already done/want doing if you'd want this to be done without the use of JS.MLeFevre
What you need is java script not PHP see http://api.jquery.com/click/ and api.jquery.com/jQuery.getBaba
I understood. I will try now using JS and Ajax. Thank you so muchAditya Goenka

2 Answers

3
votes

PHP (typically) has nothing to do with graphical user interfaces. The user interface you are probably talking about is HTML in the browser. The HTML way of doing this is a checkbox/radio button in a form with a submit button. Possibly the images can be the submit button instead. For something more dynamic, you need to use Javascript.

0
votes

The problem in this case seems to be having a record of the image clicked by user.

  1. If the images are 3 separate images, then img tags may record the clicked image, either as part of a form (server-side) or javascript (client side)

  2. If the 3 images are part of one larger image, then image maps may be what you're after:

ismap attribute indicates a server-side image map; when clicked, the coordinates are sent to the server as a URL query string.
The usemap attribute specifies an image as a client-side image map (an image map is an image with clickable areas).