[Mapserver-users] Re: php & javascript

pkishor_98 pkishor at geoanalytics.com
Thu Jun 5 12:21:13 PDT 2003


--- In mapserver-users at yahoogroups.com, Agneta Schick <schick at s...> wrote:

I'll try to answer some, but I may not have understood the exact
nature of your question --


> I need php (or Perl) for interfacing our INGRES database. 

with Perl you could use DBI and see if there is an INGRES DBD. With
PHP, well, searching on PHP boards for INGRES drivers should yield the
answer to you.

> So I
> started with a php script using Mapscript to generate maps. 
> This works fine and I can play with the URL in the browser so 
> that zoom and imgbox parameters produce the correct maps.

that is good. At least you are beyond the "getting Mapserver to work"
stage.

> Now I designed the layout in html and use javascript to catch
> the mouse clicks for zooming (imgbox). My problem is that I don't 
> understand how javascript starts the php script which then returns
> the correct image-url so that only the map image is updated.

well, JavaScript (js) doesn't start PHP... js is client-side (not
really, but lets assume so for this application) and only available in
the user's browser. PHP is server side and has nothing whatsoever to
do with the browser. The communication between the two is http GET or
POST requests. You use js to populate form (in case of POST) variables
and submit the page (the form), or populate url variables (in case of
GET) and submit the page... once these values reach the server, PHP
takes over, uses the values to create the new map, prepare a new page,
and send it back to the user via the web server.

> 
> Doing something like
'document.image_name.src=myscript.php?redraw=1&imgbox...'
> results in an empty image with the property  
> "http://.../myscript.php?redraw=1&imgbox..." 

I am not even sure if that is a valid img.src value... if you are
changing the img.src value on the fly, typically you provide a valid
path to the image be it on the server anywhere in the world, or in the
browser's cache if pre-fetched.

> 
> And sending a form-submit results in a new page. 
> How do I get just the image updated (e.g. as an image button or
image in a 
> table)??

so, you don't want to submit the page and only want the image updated.
You can't do that with straight html (at least afaik). You can
simulate it by using frames and updating only the frame containing the
map, or you need the Java applet solution whereby the image inside the
applet gets updated by communicating directly with the server... the
page containing the image remains static, so to say.

Hope this little primer sets you on the right path to where you wanna go.





More information about the MapServer-users mailing list