Kenneth, howdy...everything is fine but, i can't encode 'ID IN ('.$res.')'. What should i do now
irwan wrote: > > wow many thanks!! you help me a lot. > > > Kenneth Skovhede, GEOGRAF A/S wrote: >> >> This is the filter: >> >> $QueryFilter='Drawing+%3D+%26apos%3B74%26apos%3B+AND+Dept+%3D+%26apos%3B136%26apos%3B' >> >> >> For some reason the PHP xml system does not seem to autoencode the >> stuff, you must xml encode your input. >> I don't know why the above is url encoded though. >> >> The un-encoded filter should look like: >> $QueryFilter = 'Drawing = "3B74" AND Dept = "3B136"' >> >> The Xml encoded version should look like this: >> $QueryFilter = 'Drawing = "3B74" AND Dept = "3B136"' >> No expert on PHP functions, but I found this to help you out: >> http://vantol.org/node/31 >> >> The $QueryFilter is the string you should change to match your list of >> values. >> Build the list like this: >> >> $res = ''; >> >> while(odbc_fetch_row($rs)) >> { >> $bl_id=odbc_result($rs,"bl_id"); >> $res .= $bl_id; >> $res .= ','; >> } >> >> $res = substr($res, 0, -1); //Remove the last , >> $QueryFilter = xmlencode('ID IN ('.$res.')'); >> >> >> (Note: If the values are not integers, they have to be surrounded with >> quotes). >> (Note: You filter column in the SDF may not be called ID). >> (Note: xmlencode is the function from the link given) >> >> Regards, Kenneth Skovhede, GEOGRAF A/S >> >> irwan skrev: >>> >>> Kenneth Skovhede, GEOGRAF A/S wrote: >>> >>>> IIRC, something is broken, so you can't filter on a joined database. >>>> Instead, you can select keys from the database with an sql like this: >>>> select distinct key from table where somecolumn = 'somecriteria'; >>>> >>>> The sql should then give you a list of keys. >>>> You can then set the layer filter like this: >>>> "ID" IN (...comma seperated key list...) >>>> ea: "ID" IN ('1','A') >>>> >>>> Regards, Kenneth Skovhede, GEOGRAF A/S >>>> >>>> >>>> >>> i really stucked! really dont have an idea to change Filter element in >>> xml.what i want to know here is how to pass a value that i get from sql >>> query(php) to xml?i have create a php script, a very simple one to query >>> data from database. >>> >>> $wr_selected="SELECT * FROM wr WHERE bl_id = 'Rev"; >>> >>> $rs=odbc_exec($conn,$wr_selected); >>> >>> >>> while(odbc_fetch_row($rs)) >>> { >>> $bl_id=odbc_result($rs,"bl_id"); >>> } >>> >>> currently $bl_id hold a value that satisfy a query. So i want this value >>> put >>> into the <Filter></Filter> element in xml file such as <Filter>BL_ID IN >>> $bl_id</Filter> but i know this is something we cannot do. >>> I look at this code from >>> >>> >>> $QueryFilter='Drawing+%3D+%26apos%3B74%26apos%3B+AND+Dept+%3D+%26apos%3B136%26apos%3B' >>> >>> // Load the Query Match Layer Definition template into a PHP DOM >>> object >>> and >>> // modify its Filter node so we're displaying the right building and >>> floor. >>> $doc = DOMDocument::load('QueryMatch.LayerDefinition.xml'); >>> $FilterNode = $doc->getElementsByTagName('Filter')->item(0); >>> $FilterNode->nodeValue = $QueryFilter; >>> $LayerDefinition = $doc->saveXML(); >>> $byteSource = new MgByteSource($LayerDefinition, >>> strlen($LayerDefinition)); >>> $byteSource->SetMimeType(MgMimeType::Xml); >>> $tempResourceID = new >>> MgResourceIdentifier("Library://HumboldtFM/Layers/QueryMatch.LayerDefinition"); >>> >>> $resourceService->SetResource($tempResourceID, >>> $byteSource->GetReader(), >>> null); >>> >>> but i really dont know that to do with this code. Can someone here >>> assist >>> me? >>> >> >> _______________________________________________ >> mapguide-users mailing list >> mapguide-users@lists.osgeo.org >> http://lists.osgeo.org/mailman/listinfo/mapguide-users >> >> > > -- View this message in context: http://n2.nabble.com/invalid-XML-document-tp2149327p2161106.html Sent from the MapGuide Users mailing list archive at Nabble.com. _______________________________________________ mapguide-users mailing list mapguide-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapguide-users