Jump to content


Photo

Interacting with images


  • Please log in to reply
1 reply to this topic

#1 Arekanderu

Arekanderu
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 11 April 2006 - 02:21 PM

Hello All!

I will describe a small problem of mine and i am hoping that somebody can give me an elegant solution.

[What I want to do]

I am developing a PHP application which it will output at the user a small image with various objects on fixed positions on the image. The user will then be able to drag the mouse on a object, click on it and output information about it. e.g object type, sizeetc. The info for each object are stored in a MySQL db.

[The question]

As you understand i want to dynamically load the information for each object each time a user "clicks" on a object . What i am having trouble with is HOW am i going to put clickable stuff inside a static image ( the map ) and through PHP will be able to output some useful info to the user. In addition, the image should also be drawn dynamically since i want to show at the user which object is at the moment ocupied by being red ( this info will also be at the DB ). I know that you can do this through GDI but how am i going to do it if i want to combine it with the other thing.

If my question isn't that clear or if you think i can help more understanding it please let me know.

I have found couple solutions which i do not like so it would really save me some time if anyone has any suggestions. I do not mind using other stuff inside my PHP code ( e.g jscript ) in order to get where i want.

Somebody did suggest me map tag of HTML but i want something more dynamic.

Cheers and thanks for any replies!

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 12 April 2006 - 06:37 AM

If you use a form image

<INPUT type='image' src='myimage.php' name='myimage'>

Then it will behave like a button, submitting the form when clicked.

To process

$xpos = $POST['myimage_x'];

$ypos = $POST['myimage_y'];

You now have the coords of the mouseclick within the image. If you know the positions of the objects in your image then you can determine which object was clicked.


If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users