[Geomoose-users] Need help with ELSE / OR statements
Dan Little
danlittle at yahoo.com
Thu Aug 19 14:05:20 EDT 2010
Good news, GM2.2 can do this! :) Bad news... GM1.6 is harder and you need to use
manual SQL.
$clauses = array();
if($field == "TRS") {
array_push($clauses, "TRS like '%".$searchval$."%'");
}
if($field2 == "DOCTYPE") {
array_push($clauses, "DOCTYPE LIKE '".$searchval2."%'");
}
$all_clauses = implode(" or ", $clauses);
$rs = $conn->Execute("SELECT * FROM Surveyor_Image_Link WHERE ".$all_clauses."
ORDER BY ".$sort." ASC");
>
>From: Jim Dahl <jim.dahl at mail.co.douglas.mn.us>
>To: geomoose-users at lists.sourceforge.net
>Sent: Thu, August 19, 2010 9:56:08 AM
>Subject: [Geomoose-users] Need help with ELSE / OR statements
>
>
>I am trying to add two search fields in my GM app. I can make each field
>search correctly by themselves but not together. I have the code where the
>first two lines work and when I comment out the first two and enable the second
>two lines, the code works for searchval2. What I want to know is how can I use
>ELSE with or without the OR statements to allow me to enable both fields for
>the search?
>
> if ($field == "TRS") {
> $rs = $conn->Execute("SELECT * FROM Surveyor_Image_Link WHERE TRS LIKE
>'%".$searchval."%' ORDER BY ".$sort." ASC");
>// ) if ($field2 == "DOCTYPE") {
>// $rs = $conn->Execute("SELECT * FROM Surveyor_Image_Link WHERE DOCTYPE
>LIKE '".$searchval2."%' ORDER BY ".$sort." ASC");
> } else {
> echo "You have reached this page by mistake.";
> }
>
>
>Jim Dahl, GISP
>GIS Coordinator
>Douglas County Public Works
>526 Willow Dr
>PO Box 398
>Alexandria MN 56308
>V 320-762-2933
> 320-762-2999
>F 320-762-2998
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/geomoose-users/attachments/20100819/ad7f899b/attachment.html
More information about the Geomoose-users
mailing list