Page 1 of 1

Image maps! Getting user input for later mysql and php...

Posted: Wed Dec 06, 2006 6:09 pm
by jakeyman_i_am
Hello! I am new to the world of PHP and to this forum.

Have any of you ever used a HTML image map to get inforation to php for handling? I know how to make an image map for links, mailtos, ext, but have no idea how to link data to a spot on an image.

Here is what I am trying to do:
I must design a image which represents a fake resturant. The user will be shown the layout of the floorplan first, and be able to click on the table they desire. The HTML image map will sumbit data to the php file to check against the mysql database and see what times that table is available, and give the user the option to reserve it. What would be the best way to do this?


Thank you for all of your time/help!

Posted: Wed Dec 06, 2006 6:25 pm
by feyd
It's been quite a while since I used an image map, so I may be off here.

If memory serves, you can tell the image map a specific URL to go to when clicking in the regions. This could be used to generate a get request.

I also seem to remember where it could send coordinates to the accepting page. This could also be used with a bit of math to know which table they clicked on, or empty space.

In either case it should be fairly simple.

Posted: Wed Dec 06, 2006 7:07 pm
by jakeyman_i_am
feyd wrote:If memory serves, you can tell the image map a specific URL to go to when clicking in the regions. This could be used to generate a get request.
ok so something like this your thinking:

Code: Select all

<img src ="planets.gif"
width ="145" height ="126"
alt="Planets"
usemap ="#planetmap" />

<map id ="planetmap"
name="planetmap">
<area shape ="rect" coords ="0,0,82,126"
  href ="target.php" value="clicked1" target ="_blank"
  alt="Sun" />
<area shape ="circle" coords ="90,58,3"
  href ="target.php" value="clicked2" target ="_blank"
  alt="Mercury" />
</map>
With the values thrown in there like that it would be somewhat like a form in html. Your saying that is works something like this? It would be KILLER if this is how it worked. Thank you for your time thus far

Posted: Wed Dec 06, 2006 7:11 pm
by John Cartwright
yea, except change your href to indicate what room you looked on, for instance, href ="target.php?roomid=14", to which you can access using $_GET['roomid'] and perform neccesary checks your database.

Posted: Wed Dec 06, 2006 7:25 pm
by jakeyman_i_am
Jcart wrote:yea, except change your href to indicate what room you looked on, for instance, href ="target.php?roomid=14", to which you can access using $_GET['roomid'] and perform neccesary checks your database.
Ok, I will give that a swing tomorrow, and report how it goes. Thank you both very much!