# How do you make an image map in PHP?



## namenotfound (Apr 30, 2005)

On some sites I've seen images that when you hover over certain parts you see something like

map.php?000,111
map.php?66,666
etc.

How do you make a map in PHP?


----------



## erick295 (Mar 27, 2005)

That doesn't mean the map was created in PHP - all the links are just pointing to a PHP file.

If you want, it's possible to create one dynamically. Just write a PHP program that generates the HTML.

etc.


----------



## Shadow2531 (Apr 30, 2001)

You want a server side image map.


```
<a href="map.php"><img src="map.png" ismap="true" alt=""></a>
```
What you make the php script do with the coordinates is up to you.


----------



## jiml8 (Jul 3, 2005)

namenotfound said:


> On some sites I've seen images that when you hover over certain parts you see something like
> 
> map.php?000,111
> map.php?66,666
> ...


Here is the PHP code that makes the maps that can be seen here:
http://www.softwareforlandlords.com/moreinfo.php

Click on any of the "More Information" links to get to the page that has the relevant map. Note that I pass the name of the image placed onto the page into the routine that builds the map in order to determine how to set up the map, and I pass the image name when you click on one of the map links in order to maintain state information downstream in the site.

```
<?php
function setourmap($imagenm)  {
if ($imagenm<>"EnterEd.gif") {
  echo "

  ";
  if ($imagenm <> "persed.gif") { echo "
     ";
    }
    else { echo "
       coords=\"150, 195, 240, 220\">";
    }
  }
  if ($imagenm<>"persed.gif") {
    echo "

  ";
  if ($imagenm<> "persed.gif" and $imagenm<> "StdEd.gif"){echo "
    ";
  }
  echo "

  <img border=\"0\"
  src=$imagenm usemap=\"#FPMap0\"
  width=\"384\" height=\"338\">

";
}
else
{ echo "

  <img border=\"0\"
  src=$imagenm usemap=\"#FPMap0\"
  width=\"384\" height=\"338\">

";
}
echo "

[B]click on a form button to view details and screenshots[/B]

Form background is user configurable

";
}
```


----------

