R: [maplab-users] code for custom query (Sorry for previous mail)

charley cheng chengcharlie2003 at yahoo.ca
Fri Aug 20 00:51:31 EDT 2004


Hi Alberto,
Thank you very much! I tried it and it works fine.
Charlie

Alberto Cavalli <alberto.cavalli at sintranet.it> wrote:
 Hi Charlie,
the code is very simple and it is only a starting point for building a custom query:
INFO, NUM_FOGLIO, NUM_PART, AREA, INFO_ID and ESPR1 are the fields of dbf of one layer. 
 

//loop and use key for titles## field from dbf that you want to display when you make a query

foreach ($aRows[0] as $key => $value)
{
if (strcasecmp($key, "INFO") == "INFO" ||
strcasecmp($key, "NUM_FOGLIO") == "NUM_FOGLIO" ||
strcasecmp($key, "NUM_PART") == "NUM_PART" ||
strcasecmp($key, "AREA") == "AREA" )

This part of code generate the titels of field that appear when you make a query


 

// loop and add a cell for each result## field that you don't want to display when you make a query
foreach ( $aRow as $key => $xCell )
{
if (strcasecmp($key, "INFO_ID") == 0 ||
strcasecmp($key, "ESPR1") == 0)
This part of code remove the value of field thath you don't want to display
 
 
 
 
 
use the same way to customize a query for multiple layer
for example:
first layer dbf: 3 field (id, area perimeter)
second layer dbf: 2 layer (name, dimension)
If you want to display only id, area and dimension use this is the code
 

// loop and use key for titles## CAMPI DA INCLUDERE
foreach ($aRows[0] as $key => $value)
{
if (strcasecmp($key, "ID") == "ID" ||
strcasecmp($key, "AREA") == "AREA" ||
strcasecmp($key, "DIMENSION") == "DIMENSION" )

$szReturnValue .= "<td bgcolor=\"E2EFF5\"><font face=\"Arial, Helvetica, sans-serif\" size=\"2\">".$key."</font></td>\n";
}
$szReturnValue .= "</tr>\n";

// loop through the results and format each row
foreach ( $aRows as $aRow )
{
// add a row for each
$szReturnValue .= "</tr>\n";

// loop and add a cell for each result## CAMPI DA ESCLUDERE
foreach ( $aRow as $key => $xCell )
{
if (strcasecmp($key, "NAME") == 0 ||
strcasecmp($key, "PERIMETER") == 0)
continue;
$szReturnValue .= "<td bgcolor=\"E2EFF5\"><font face=\"Arial, Helvetica, sans-serif\" size=\"2\">".$xCell."</font></td>\n";
}

$szReturnValue .= "</tr>\n";
}

Very important: be careful, use the righr sequency of field!!!!!!!!

 

 

Have a good work

Alberto

 
 
-----Messaggio originale-----
Da: charley cheng [mailto:chengcharlie2003 at yahoo.ca]
Inviato: gioved?19 agosto 2004 6.31
A: Alberto Cavalli
Cc: maplab help
Oggetto: Re: [maplab-users] code for custom query (Sorry for previous mail)


Hi! Alberto,
For unknown reasons, my previous mail has been cut. I am terrible sorry for it! I have to send again.
 
Thank you very much  for you code! I  really need the code to display the only attributes in shapefile I want display.
 
Could you give me a little more explaination about your code?
INFO, NUM_FOGLIO, NUM_PART, AREA are the attributes in shapefile you want to display.
What is INFO_ID and ESPR1?
 
Thank you very much!
 
Charlie





---------------------------------
Post your free ad now! Yahoo! Canada Personals
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/maplab-users/attachments/20040820/f3b0e40b/attachment.htm


More information about the Maplab-users mailing list