[postgis-users] postgis mapfile php

Brent Wood pcreso at pcreso.com
Mon Apr 7 00:04:38 PDT 2008


Try:

DATA "the_geom from europe_country where country='%country%' using unique gid
using srid=-1"

& make sure you pass the value for country in your HTML template,

I have a similar app highlighting a species cautght during a biodiversity
survey:

The mapfile has a layer using an SQL to select the text to match for a given
species (I'm using like, so need the double '%%', it uses a query to generate a
virtual table which contains the result of the query, & I used the name myquery
for this virtual table:

LAYER
    NAME spp
    TYPE line
    STATUS on
    CONNECTIONTYPE POSTGIS
    CONNECTION "dbname=stations user=baw host=localhost port=5432"
    DATA "track from (select track,
                             station_no
                       from station where station_no in
                        (select distinct station_no from catch
                         where species like '%%spp%%')
                       order by station_no)
                        as myquery using unique station_no using srid=4326"
....

The html template allows users to enter the species code & turn the layer on:

...
      <INPUT type=checkbox name=layer value="spp" [spp_check]>Species  
      <INPUT type="text" name="spp" size=3  value="[spp]" >
...

I think this is the sort of thing you are looking for?

Also, you have an error in your SQL below,
 
the_geom from europe_country where name="Greece"

the " should be ' around the string 'Greece' for a Postgres string query.

If you turn debug on in mapserver, you can see the Postgres error message
displayed on screen when you open the page in your browser, to help diagnose &
fix errors like this.


Cheers,

   Brent Wood


> nickthegreek- wrote:
> > 
> > i have map who takes the data from a database
> > 
> > in the database there is a column "name"
> > 
> > my data are be shown with
> > 
> >  LAYER
> >                 NAME "country"
> >                 TYPE POLYGON
> >                 STATUS ON
> >             CONNECTIONTYPE postgis
> >             CONNECTION "host=localhost dbname=postgis user=postgres
> > password=d3klw7 port=5432"
> >             DATA "the_geom from europe_country using unique gid using
> > srid=-1"
> >             LABELITEM "name"
> > 
> > what i wanna is.. i have a menu who takes all the countries from the
> > column name...
> > if i select a country
> > 
> > eg.greece
> > 
> > how i could change the statement in the mapfile
> > DATA "the_geom from europe_country using unique gid using srid=-1"
> > with the statement
> > DATA "the_geom from europe_country where name=greece using unique gid
> > using srid=-1" so to be shown only greece??? pls help me..i need to finish
> > my diploma with taht
> > 
> > 
> > eg..i knnow if we wanna to change the status of a layer we use that
> >   $this_layer = $map->getLayerByName('europe cities');
> >   $this_layer->set('status', MS_ON);
> > 
> > sth similar like the above to change the statement of data?
> > 
> 
> 
> also.. i wanna know sth else.. in the mapfile ..i have in data
> DATA "the_geom from europe_country using unique gid using srid=-1"
> 
> if i changed it in DATA "the_geom from europe_country where name="Greece"
> using unique gid using srid=-1"
>  it should be shown greece ?? right?
> 
> but nothing is shown ..it gives me error ...knows anyone what is wrong?
> -- 
> View this message in context:
> http://www.nabble.com/postgis-mapfile-php-tp16530438p16531664.html
> Sent from the PostGIS - User mailing list archive at Nabble.com.
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
> 




More information about the postgis-users mailing list