[Mapserver-users] Implementing QueryByAttribute
Vinko Vrsalovic
vinko at cprsig.cl
Mon Dec 16 08:10:32 PST 2002
On Fri, Dec 13, 2002 at 10:23:50AM -0800, Jeff Berry wrote:
> Below is the code I've included in the main PHP code of my phtml file.
> There is a textline labeled OwnerName. I get a parser error on the
> QueryByAttributes line. I don't know what I'm doing wrong.
>
> Any suggestion as to what the problem is?
I guess you need to read the PHP Manual :-)
This is a mix between Perl and PHP syntax, and that usually doesn't
work.
> if ($HTTP_FORM_VARS[OwnerName])
if ($HTTP_FORM_VARS['OwnerName'])
and it's either HTTP_POST_VARS or HTTP_GET_VARS, AFAIK
> {
> $layer->$map->getLayerByName('parcels');
> $layer->{status} = MS_ON;
Syntactically this should be:
$layer->status = MS_ON;
But, due to some limitations in PHP, it actually is:
$layer->set("status",MS_ON);
> $layer->{filteritem} = "OWNER";
the same here
> $layer->setfilter("\"$OwnerName\"");
if $OwnerName defined? shouldn't this be $HTTP_POST_VARS['OwnerName'] ?
> &rv = $layer->queryByAttributes($map, MS_SINGLE);
$rv, not &rv (if you want a reference instead of a copy, you do
$rv = & $layer....)
> if ($rv == MS_SUCCESS)
> {
> for ($i=0; $1<$layer->{resultcache}->{numresults}; $i++)
without {}'s
> {
> $result = $layer->getResult($i);
> $rvshape = $layer->getShape($shape, $result->{tileindex},
> $result->{shapeindex});
without {}'s
> $shpbnd = $rvshape->bounds;
> &map->setextent( $shpbnd->{xmin}, $shpbnd->{ymin},
> $shpbnd->{xmax}, $shpbnd->{ymax} );
likewise, $ instead of & and $shpbnd->xmax
HTH,
--
Vinko Vrsalovic <el[|- at -|]vinko.cl>
http://www.cprsig.cl
More information about the MapServer-users
mailing list