Jump to content

Image Mapping with PHP...


Neptunus Maris

Recommended Posts

Hey guys...

How do you do image mapping with php?  for example if I was doing an image map of a real map and a user clicked on a region on the map it would go to another page (show_region.php) and show its info. How could i wok that with php? or how could i bring up the links?

I know that to get the link you'd have to do this:

$query = "SELECT * FROM regions";
$result = mysql_query($query) or die(mysql_error());                  <----This stuff brings up the data info.
$region = mysql_fetch_array($result) or die(mysql_error());

//Now on the image mapping process i dont know how to do the link with the corresponding region data

//I know how to get the link of each region: <a href = 'show_region.php?regionID=$region[$regionID]'>$region['name']</a>
//Still dont know how to work it in.

I know what to do when the user clicks the link:

$regionID = $_GET['regionID']
$query = "SELECT * FROM regions WHERE regionID = '$regionID'";
$result = mysql_query($result) or die(mysql_error());
$region = mysql_fetch_array($result) or die(mysql_error());

// And then blabla from there to view the regions info.


So how can I properly put the links in on the image mapping process?

Thanks in advance,
Neptune
Link to comment
Share on other sites

OK the here is what im talking about..

At a php page, map.php, i want a user to beable to click on the map(the picture) , on any region of the map. Then it will take them to a page called show_region.php to show all the regions info.  For an example: [url=http://romanlegion.com/garrison.php?RomanSession=aa4ca0771cb21a539aa0f540548513e5]http://romanlegion.com/garrison.php?RomanSession=aa4ca0771cb21a539aa0f540548513e5[/url]

But the trick is, is how i would use PHP/MySQL with the links...to regularly get the link from a piece of data from the MySQL database is.

I know that to get the link you'd have to do this:

$query = "SELECT * FROM regions";
$result = mysql_query($query) or die(mysql_error());                  <----This stuff brings up the data info.
$region = mysql_fetch_array($result) or die(mysql_error());

Then this as the link : <a href = 'show_region.php?regionID=$region[$regionID]'>$region['name']</a>

Where can I put that link that will correspond to an image sector on the map...(that will correspond to the id of what i want to get form the database)

And then once the user clicks the link and goes to the show_region.php:

$regionID = $_GET['regionID']
$query = "SELECT * FROM regions WHERE regionID = '$regionID'";
$result = mysql_query($result) or die(mysql_error());
$region = mysql_fetch_array($result) or die(mysql_error());

The code will look like that to start the retrival of info...like

<table>
  <tr>
  <td>$region['capital']</td>
  </tr>
And bla bla bla.

Once again im just trying to figure out how to make the links to be put in the image mapping correspond to the data.

Thanks
Neptune


Link to comment
Share on other sites

What i come up with


This is only a quick 2 sec html way but you can convert all the information from the database.

For example the link the image ect ect ect ok.

[code]
<DIV ALIGN=CENTER>

<MAP NAME="map1">
<AREA
   HREF="contacts.html" ALT="Contacts" TITLE="Contacts"
   SHAPE=RECT COORDS="6,116,97,184">
<AREA
   HREF="products.html" ALT="Products" TITLE="Products"
   SHAPE=CIRCLE COORDS="251,143,47">
<AREA
   HREF="new.html" ALT="New!" TITLE="New!"
   SHAPE=POLY COORDS="150,217, 190,257, 150,297,110,257">
</MAP>

<IMG SRC="testmap.gif"
   ALT="map of GH site" BORDER=0 WIDTH=300 HEIGHT=300
   USEMAP="#map1"><BR>

[ <A HREF="contacts.html" ALT="Contacts">Contacts</A> ]
[ <A HREF="products.html" ALT="Products">Products</A> ]
[ <A HREF="new.html"      ALT="New!">New!</A> ]
</DIV>
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.