Mapscript/PHP help me display tabular results of my query (queryByAttributes)

Pietro Giannini pgiannini at BYTEWISE.IT
Thu Jun 14 00:34:15 PDT 2007


Hi John,

the result of "$layer->getResult($i)" is a result cache; you must obtain
the shape of the layer by the "shapeindex" property of the result cache:

your code:
/**********************************/
 $layer->open();

 for ($i = 0; $i <= $layer->getnumresults();$i += 1) {
 $resultx = $layer->getResult($i);

 // THIS Does NOT give me what I'm after
 print "<pre>";
 print_r($resultx); // print_r($resultx);
 print "</pre>";
 }
/**********************************/


modified:
/**********************************/
 $layer->open();

 for ($i = 0; $i <= $layer->getnumresults();$i += 1) {
 $resultx = $layer->getResult($i);
 $shape = $layer->getShape($resultx->shapeindex);

 print "<pre>";
 print_r($shape->values['string_name_of_the_field']);
 print "</pre>";
 }
/**********************************/

take a look here:
http://mapserver.gis.umn.edu/docs/reference/phpmapscript-class/classes/layerobj
http://mapserver.gis.umn.edu/docs/reference/phpmapscript-class/classes/resultcachememberobj

bye
................................pg





Pietro Giannini
Bytewise srl - Area GIS
41°50'38.58"N 12°29'13.39"E






> Hi,
>
> 	I have been looking through the Mapscript API and can't find what I'm
> looking for.  I'm just asking for help with a tip as to where to look.
> I'm trying to display the results of my query.
>
> ++++++++++++++ BEGIN CODE ++++++++++++++++++
> <?php
> dl('php_mapscript.dll');
>
> list($layername, $field) = split(",", $_GET['q']); // q is the value of
> what was selected
>
> $options = array();
> $map_path="C:\\ms4w\\Apache\htdocs\\img_browser\\";
> $map_file="imgb_access.map";
> $map = ms_newMapObj($map_path.$map_file);
>
> switch($layername) {
>    case 'landsat_4':
>      $layernum = 3;
>      $qstring = "Landsat";
>      break;
>    case 'ikonos':
>      $layernum = 4;
>      $qstring = "Ikonos";
>      break;
>    case 'hyperion':
>      $layernum = 5;
>      $qstring = "Hyperion";
>      break;
>    case 'mn_airphotos':
>      $layernum = 6;
>      $qstring = "MN DNR";
>      break;
> }
>
> $layer = $map->getlayer($layernum);
> $success = $layer->queryByAttributes($field, $qstring, MS_MULTIPLE);
> $layer->open();
>
> for ($i = 0; $i <= $layer->getnumresults();$i += 1) {
> $resultx = $layer->getResult($i);
>
> // THIS Does NOT give me what I'm after
> print "<pre>";
> print_r($resultx); // print_r($resultx);
> print "</pre>";
> }
>
> ++++++++++++++ END OF CODE ++++++++++++++++++
> The last section (with print_r) shows me the result of my query but not
> in the form that I want.  I want to see the records in the dbf table of
> the shapefile that I have queried.  What am I doing wrong ?
>
> --
> ---------------------------------------------
> John B. Churchill, M.S.			http://alx.al.umces.edu/~jchurch/
> GIS Specialist				(301) 689-7109
>
> University of Maryland Center for Environmental Science
> Appalachian Laboratory			http://www.al.umces.edu/
> Environmental Science Education		http://alese.al.umces.edu/
>
> 301 Braddock Road
> Frostburg, MD 21532
>



More information about the MapServer-users mailing list