I want to change keywords searching from CGI Model to PHP/MapScript Model. But I have some problems<br><br>something changed as follow:<br><br>petrochina_admin.xml:<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;service title=&quot;搜索管线&quot; selectable=&quot;false&quot; default=&quot;false&quot; locked=&quot;true&quot; div=&quot;buildingsearch&quot;&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;url&gt;php/search.php&lt;/url&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;input type=&quot;hidden&quot; name=&quot;map&quot; value=&quot;/ms4w/apps/GeoMOOSE/petrochina/itemquery.map&quot;/&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;input type=&quot;hidden&quot; name=&quot;mode&quot; value=&quot;nquery&quot;/&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;input type=&quot;user&quot; name=&quot;id&quot; title=&quot;Zoom to building#:&quot;/&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/service&gt;<br><br>petrochina.html:<br clear="all">&lt;div id=&quot;CustomForms&quot;&gt;<br>&nbsp;&nbsp;&nbsp; &lt;div id=&quot;Buildingsearch&quot;&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;font color=&quot;black&quot;&gt;&lt;b&gt;搜索管线:&lt;/b&gt;&lt;/font&gt;&lt;br/&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;input name=&quot;id&quot;/&gt;&lt;input type=&quot;submit&quot; value=&quot;查询&quot;/&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;input type=&quot;hidden&quot; name=&quot;map&quot; value=&quot;/ms4w/apps/GeoMOOSE/petrochina/itemquery.map&quot;/&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;input type=&quot;hidden&quot; name=&quot;mode&quot; value=&quot;nquery&quot;/&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;br&gt;&lt;i&gt;输入管线名称&lt;i/&gt;<br>&nbsp;&nbsp;&nbsp; &lt;/div&gt;<br><br>&lt;div id=&quot;WaitingMessage&quot;&gt;<br>&lt;b&gt;请稍候...&lt;/b&gt;<br>&lt;/div&gt;<br><br>and new search.php:<br>&lt;?php<br>#<br># select.php (c) 2007 Dan &quot;Ducky&quot; Little<br>
# Write for the GeoMOOSE project, sponsored by the OpenMNND Organization<br># PHP Translation of the Perl script select.pl<br>#<br><br># Make the PHP Script Shut Up, but still give something useful if there<br># is a legit error or parsing bug.<br>
error_reporting(E_ERROR | E_PARSE);<br><br># Include the GeoMOOSE PHP Library Utilities<br># Get in the information from the request<br>$coordinates = $_REQUEST[&#39;coords&#39;];<br>$title = $_REQUEST[&#39;title&#39;];<br>
$shapeType = $_REQUEST[&#39;shape&#39;];<br>$buffer = $_REQUEST[&#39;buffer&#39;];<br>$layer = $_REQUEST[&#39;layer&#39;];<br>$output = $_REQUEST[&#39;output&#39;];<br>$identifyMap = $_REQUEST[&#39;map&#39;];<br>$selectMap = $_REQUEST[&#39;select&#39;];<br>
$string = $_REQUEST[&#39;qstring&#39;];<br><br><br># Check for some vitals<br>if(!isset($layer)) {<br>&nbsp;&nbsp;&nbsp; appError(&#39;Layer value is not set or invalid: &#39;.$layer);<br>}<br>if(!isset($output)) {<br>&nbsp;&nbsp;&nbsp; $output = $DEFAULT_OUTPUT;<br>
}<br><br># Check the CGI for the layer/column Delimiter,<br># If it&#39;s not found, then use the default.<br>$delim = $_REQUEST[&#39;delim&#39;];<br>if(!isset($delim)) {<br>&nbsp;&nbsp;&nbsp; $delim = $DEFAULT_DELIM;<br>}<br># This splits the input layer sting into the Layer Name and the Column Containing the ID&#39;s for the layer<br>
list($layer, $queryColumn) = explode($delim, $layer);<br><br># This checks for the existance of the select mapfile.<br># If it does not exist the application quits with an error message.<br>if(!file_exists($selectMap)) {<br>
&nbsp;&nbsp;&nbsp; appError(&#39;Could not find: &#39;.$selectMap);<br>}<br><br># This checks to see what &quot;shape&quot; is being passed to the script to query against.<br>if($shapeType == &quot;point&quot;) {<br>&nbsp;&nbsp;&nbsp; $shapeType = MS_SHAPE_POINT;<br>
} elseif($shapeType == &#39;circle&#39;) {<br>} elseif($shapeType == &#39;line&#39;) {<br>&nbsp;&nbsp;&nbsp; $shapeType = MS_SHAPE_LINE;<br>&nbsp;&nbsp;&nbsp; if(empty($buffer)) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $buffer = 1;&nbsp;&nbsp;&nbsp; # Makes the line work if there is no buffer specified or the buffer = 0<br>
&nbsp;&nbsp;&nbsp; }<br>} else {<br>&nbsp;&nbsp;&nbsp; $shapeType = MS_SHAPE_POLYGON;<br>}<br><br><br># Convert the coordinates to a new shape object<br># This takes the coordinates from the CGI and adds them to a Shape for querying.<br>$shape = ms_newShapeObj($shapeType);<br>
$coords = array();<br>$coords = explode(&#39; &#39;, $coordinates);<br>$line = ms_newLineObj();<br>foreach ($coords as $coord) {<br>&nbsp;&nbsp;&nbsp; list($x, $y) = explode(&#39;,&#39;,$coord);<br>&nbsp;&nbsp;&nbsp; $line-&gt;addXY($x,$y);<br>}<br>$shape-&gt;add($line);&nbsp;&nbsp;&nbsp; # This adds the line with all the coordinates from the CGI<br>
#$shape-&gt;setBounds();&nbsp;&nbsp;&nbsp; # This initalizes the shape.<br><br># Buffer as desired.<br>if(isset($buffer)) {<br>&nbsp;&nbsp;&nbsp; $shape = $shape-&gt;buffer($buffer);&nbsp;&nbsp;&nbsp; # Mapscript using GEOS to bufffer the shape<br>&nbsp;&nbsp;&nbsp; if(!isset($shape)) { &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # Check to make sure the function returned a valid shape, if not, error.<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; appError(&quot;Buffering Failed. Buffer size: $buffer. Verify mapscript was linked with GEOS and that the buffer is a positive-real number.&quot;);<br>&nbsp;&nbsp;&nbsp; }<br>}<br><br># Create a new Coordinate string based on any potential buffering.<br>
# This is needed because after the object has been buffered it will have a new coordinate string.<br># This information is passed back to the GeoMOOSE client so that it can set the &quot;mapshape&quot; parameter<br># which displays the layer highlighting.<br>
$coordString = &#39;&#39;;<br>for($line = 0; $line &lt; $shape-&gt;{numlines}; $line++) {<br>&nbsp;&nbsp;&nbsp; $lineObj = $shape-&gt;line($line);<br>&nbsp;&nbsp;&nbsp; for($point = 0; $point &lt; $lineObj-&gt;{numpoints}; $point++) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $pointObj = $lineObj-&gt;point($point);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $coordString = $coordString.$pointObj-&gt;{x}.&#39; &#39;.$pointObj-&gt;{y}.&#39; &#39;;<br>&nbsp;&nbsp;&nbsp; }<br>}<br><br># Set up the query to perform the select, with the buffer and all!<br># If the Map does not open correctly, error out.<br>
$queryMap = ms_newMapObj($selectMap) or appError(&#39;Could not open mapfile: &#39;.$selectMap.&quot;\n&quot;.&#39;Please verify the Map file is valid.&#39;);<br><br># This section of code searches for the query layer.<br>
# If a layer is not the query layer, it is turned off so that errorneous/extraneous results are not<br># also returned.&nbsp; This also helps speed queries so that multiple large datasets are not simultaneously queried.<br>$queryLayerFound = false;&nbsp;&nbsp;&nbsp; # Set an error condition in case we do not find the layer<br>
for($l = 0; $l &lt; $queryMap-&gt;{numlayers}; $l++) {<br>&nbsp;&nbsp;&nbsp; $queryLayer = $queryMap-&gt;getLayer($l);<br>&nbsp;&nbsp;&nbsp; $queryLayer-&gt;set(&#39;status&#39;, MS_OFF);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # Turn the layer off<br>&nbsp;&nbsp;&nbsp; if($queryLayer-&gt;{name} == $layer) {&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # If it&#39;s the layer we&#39;re trying to search...<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $queryLayer-&gt;set(&#39;status&#39;,MS_ON);&nbsp;&nbsp;&nbsp; # Turn it on!<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $queryLayerFound = true;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # &quot;Unset&quot; the Error Condition<br>&nbsp;&nbsp;&nbsp; }<br>}<br><br>if(!$queryLayerFound) {&nbsp;&nbsp;&nbsp; # If they layer is not found in the mapfile, error out.<br>
&nbsp;&nbsp;&nbsp; appError(&quot;The Query Layer &#39;$layer&#39; could not be found in the mapfile ($selectMap).&quot;);<br>}<br># Perform the Query.<br>//$qstring=&#39;大&#39;;<br># select a Chinese char as example<br>$searchstring=iconv(&quot;gbk&quot;, &quot;ISO-8859-13&quot;, $qstring);<br>
# charset convert<br>$searchstring=&quot;/&quot;.$searchstring.&quot;/&quot;;<br>$searchstring=&quot;/&quot;.$qstring.&quot;/&quot;;<br><br>$queryMap= $queryMap-&gt;getLayerByName($layer); <br>$queryMap-&gt;set(&quot;status&quot;, MS_ON); <br>
<br>$queryResultCheck = $queryMap-&gt;queryByAttributes(&#39;Name&#39;, $searchstring, MS_SINGLE);;<br>if($queryResultCheck == MS_FAILURE) {&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # If the query fails, error out.<br>&nbsp;&nbsp;&nbsp; # Check to see if the Map has any pointers to an empty file<br>
&nbsp;&nbsp;&nbsp; $empty = $queryMap-&gt;web-&gt;empty;<br>&nbsp;&nbsp;&nbsp; # If it&#39;s set then show that HTML instead. :D<br>&nbsp;&nbsp;&nbsp; if(isset($empty) and $empty != &#39;&#39;) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; readfile($empty);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; exit(0);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; } else {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; appError(&#39;查询返回结果失败!&#39;);<br>&nbsp;&nbsp;&nbsp; }<br>}<br><br># Cycle through the results of the query and build an array containing the results.<br>$resultContents = array();<br>for($l = 0; $l &lt; $queryMap-&gt;{numlayers}; $l++) {&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # Cycle through the layers<br>
&nbsp;&nbsp;&nbsp; $queryLayer = $queryMap-&gt;getLayer($l);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # Get they layer object from the map.<br>&nbsp;&nbsp;&nbsp; if($queryLayer-&gt;{name} == $layer) {&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # Check to make sure it&#39;s our layer of interest.<br>#&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $queryResults = $queryLayer-&gt;getResults();&nbsp;&nbsp;&nbsp; # Get the results from the query.<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $queryColumns = array();&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # Hash table to hold the column names.<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $queryLayer-&gt;open();&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # Open the layer for operation.<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # This loop deserves from definition.<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # What this look is doing is creating a assosciative array (hash table) containing the shapefile<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # indexes of the column names<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # Example:&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # &nbsp;&nbsp;&nbsp; A layer could contain the following columns: 0 - ID, 1 - OWNER, 2 - CITY<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # &nbsp;&nbsp;&nbsp; This loop would create an associative array that has the indexes of {&#39;ID&#39;,&#39;OWNER&#39;,&#39;CITY&#39;} and the corresponding values {0,1,2}<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # &nbsp;&nbsp;&nbsp; Ergo, $queryColumns{&#39;OWNER&#39;} will return 0<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for($item = 0; $item &lt; $queryLayer-&gt;{numitems}; $item++) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $queryColumns{$queryLayer-&gt;getItem($item)} = $item;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if($queryLayer-&gt;getNumResults() &gt; 0) {&nbsp; # Check to make sure we have SOME results<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; #&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for($result = 0; $result &lt; $queryResults-&gt;{numresults}; $result++) {&nbsp;&nbsp;&nbsp; # Loop through the results<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for($result = 0; $result &lt; $queryLayer-&gt;getNumResults(); $result++) {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # Get the member of the result set<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $queryResult = $queryLayer-&gt;getResult($result);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # Get the feature from that result.<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # I left getFeature in here, as getShape will be deprecated for getFeature<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; #$queryFeature = $queryLayer-&gt;getFeature($queryResult-&gt;{shapeindex}, $queryResult-&gt;{tileindex}); <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $queryFeature = $queryLayer-&gt;getShape($queryResult-&gt;{tileindex}, $queryResult-&gt;{shapeindex}); <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # Here&#39;s where the array from before becomes very handy.&nbsp; The column *name* is passed<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # into the CGI, so we need to result the shapefile-column index and the name,<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # which is query %queryColumns does! So now, we can just pull the ID column from the object.<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $v = $queryFeature-&gt;{values}[$queryColumn];<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # And put that ID onto the stack of results...<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; array_push($resultContents, $v);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } else {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; appError(&#39;选定图层没有任何查询结果&#39;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $queryLayer-&gt;close(); # Close the layer<br>&nbsp;&nbsp;&nbsp; }<br>}<br><br># Process the query template from the mapfile and return it to the user<br># This way the results are displayed exactly as they are definied in the mapfile.<br>
$template = $queryMap-&gt;processQueryTemplate(array(), array());<br><br>if($output == &#39;xml&#39;) {<br>&nbsp;&nbsp;&nbsp; header(&#39;Content-type: text/xml; charset=gbk&#39;);<br>&nbsp;&nbsp;&nbsp; # Return the XML that tells GeoMOOSE what to do!<br>
&nbsp;&nbsp;&nbsp; #<br>&nbsp;&nbsp;&nbsp; # By passing &quot;mapbook fragments&quot; back to GeoMOOSE we can change the behavior and <br>&nbsp;&nbsp;&nbsp; # definition of the maps being displayed.&nbsp; $layer contains the mapbook name of the <br>&nbsp;&nbsp;&nbsp; # layer we were selecting-against.&nbsp; The &quot;&lt;param.../&gt;&quot; line will set the mapshape parameter for<br>
&nbsp;&nbsp;&nbsp; # the layer we selected against.<br>&nbsp;&nbsp;&nbsp; print &quot;&lt;return&gt;&quot;;<br>&nbsp;&nbsp;&nbsp; printf(&quot;&lt;map title=&#39;Highlight&#39; default=&#39;true&#39;&gt;&quot;, $layer);<br>&nbsp;&nbsp;&nbsp; printf(&quot;&nbsp;&nbsp;&nbsp; &lt;file&gt;%s&lt;/file&gt;&quot;, $identifyMap);<br>
&nbsp;&nbsp;&nbsp; $strippedLayer = preg_replace(&quot;/ /&quot;,&#39;&#39;,$layer);<br>&nbsp;&nbsp;&nbsp; printf(&quot;&nbsp;&nbsp;&nbsp; &lt;param name=&#39;layers&#39; value=&#39;%s&#39;/&gt;&quot;, $strippedLayer);<br>&nbsp;&nbsp;&nbsp; printf(&quot;&nbsp;&nbsp;&nbsp; &lt;param name=&#39;qlayer&#39; value=&#39;%s&#39;/&gt;&quot;, $strippedLayer);<br>
&nbsp;&nbsp;&nbsp; printf(&quot;&nbsp;&nbsp;&nbsp; &lt;param name=&#39;mapshape&#39; value=&#39;%s&#39;/&gt;&quot;, $coordString);<br><br>&nbsp;&nbsp;&nbsp; # This takes the ID&#39;s from the results stack and puts it inside the layer.<br>&nbsp;&nbsp;&nbsp; foreach ($resultContents as $id) {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; #&nbsp;&nbsp;&nbsp; print &quot;\t\t&lt;selected id=&#39;$id&#39;/&gt;\n&quot;;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; printf(&quot;&nbsp;&nbsp;&nbsp; &lt;selected id=&#39;%s&#39;/&gt;&quot;, $id);<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; print &quot;\t&lt;/map&gt;&quot;;<br><br>&nbsp;&nbsp;&nbsp; # Print some header information.<br>
&nbsp;&nbsp;&nbsp; print &#39;&lt;results title=&quot;Select Results&quot;&gt;&#39;;<br>&nbsp;&nbsp;&nbsp; print &#39;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;header&gt;&lt;col value=&quot;Selected Objects:&quot;/&gt;&lt;/header&gt;&#39;;<br>&nbsp;&nbsp;&nbsp; print &quot;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;row&gt;&lt;col value=&#39;&quot;.count($resultContents).&quot;&#39;/&gt;&lt;/row&gt;&quot;;<br>
&nbsp;&nbsp;&nbsp; print &#39;&lt;/results&gt;&#39;;<br><br><br>&nbsp;&nbsp;&nbsp; print $template;<br><br>&nbsp;&nbsp;&nbsp; print &quot;&lt;/return&gt;&quot;;&nbsp;&nbsp;&nbsp; # End the XML Page.<br>} elseif($output == &#39;html&#39;) {<br>&nbsp;&nbsp;&nbsp; header(&#39;Content-type: text/html; charset=gbk&#39;);<br>
&nbsp;&nbsp;&nbsp; #gbk is charset sopport Chinese<br>&nbsp;&nbsp;&nbsp; ## HTML OUTPUT<br>&nbsp;&nbsp;&nbsp; # This is a HTML/XML trick that uses XML namespaces in order to embed a GeoMOOSE<br>&nbsp;&nbsp;&nbsp; # mapbook into a HTML document.<br>&nbsp;&nbsp;&nbsp; print &#39;&lt;html xmlns:moose=&quot;<a href="http://geomoose.org/">http://geomoose.org/</a>&quot;&gt;&#39;;<br>
&nbsp;&nbsp;&nbsp; print &quot;&lt;head&gt;\n&quot;;<br>&nbsp;&nbsp;&nbsp; print &quot;&lt;moose:mapbook&gt;\n&quot;;<br>&nbsp;&nbsp;&nbsp; #&nbsp;&nbsp;&nbsp; print &quot;&lt;moose:map title=&quot;&#39;.$layer.&#39;&quot; default=&quot;true&quot;&gt;\n&quot;;<br>&nbsp;&nbsp;&nbsp; printf(&quot;&lt;moose:map title=&#39;Highlight&#39; default=&#39;true&#39;&gt;\n&quot;,$layer);<br>
&nbsp;&nbsp;&nbsp; printf(&quot;&nbsp;&nbsp;&nbsp; &lt;moose:file&gt;%s&lt;/moose:file&gt;&quot;, $identifyMap);<br>&nbsp;&nbsp;&nbsp; $strippedLayer = preg_replace(&quot;/ /&quot;,&#39;&#39;,$layer);<br>&nbsp;&nbsp;&nbsp; printf(&quot;&nbsp;&nbsp;&nbsp; &lt;moose:param name=&#39;layers&#39; value=&#39;%s&#39;/&gt;&quot;, $strippedLayer);<br>
&nbsp;&nbsp;&nbsp; printf(&quot;&nbsp;&nbsp;&nbsp; &lt;moose:param name=&#39;qlayer&#39; value=&#39;%s&#39;/&gt;&quot;, $strippedLayer);<br>#&nbsp;&nbsp;&nbsp; print &quot;&nbsp;&nbsp;&nbsp; &lt;moose:param name=&#39;mapshape&#39; value=&#39;&quot;.$coordString.&quot;&#39;/&gt;\n&quot;;<br>
&nbsp;&nbsp;&nbsp; printf (&quot;&lt;moose:param name=&#39;mapshape&#39; value=&#39;%s&#39;/&gt;\n&quot;, $coordString);<br>&nbsp;&nbsp;&nbsp; foreach ($resultContents as $id) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; printf(&quot;&nbsp;&nbsp;&nbsp; &lt;moose:selected id=&#39;%s&#39;/&gt;\n&quot;, $id);<br>
&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; print &quot;&lt;/moose:map&gt;\n&quot;;<br>&nbsp;&nbsp;&nbsp; print &quot;&lt;/moose:mapbook&gt;\n&quot;;<br>&nbsp;&nbsp;&nbsp; print &quot;&lt;/head&gt;&quot;;<br>&nbsp;&nbsp;&nbsp; print &quot;&lt;body&gt;&quot;;<br>&nbsp;&nbsp;&nbsp; print &quot;&lt;![CDATA[&quot;;<br>
&nbsp;&nbsp;&nbsp; print $template;<br>&nbsp;&nbsp;&nbsp; print &quot;]]&gt;&quot;;<br>&nbsp;&nbsp;&nbsp; print &quot;&lt;/body&gt;&quot;;<br>&nbsp;&nbsp;&nbsp; print &quot;&lt;/html&gt;&quot;;<br>} else {<br>&nbsp;&nbsp;&nbsp; appError(&#39;Unrecognized output option: &#39;.$output);<br>}<br><br>
exit; # End the Program!<br>?&gt;<br><br><br>but it doesn&#39;t work,Someone can help me?<br>-- <br>Leopard<br>