close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

search for only some criteria

Thread began 10/29/2010 1:27 pm by i.edwards384429 | Last modified 11/01/2010 5:50 pm by Jason Byrnes | 858 views | 7 replies |

i.edwards384429

search for only some criteria

Hi

thanks to all the help I now have a working results page with a non exact search.

So I took a backup copy and started testing , realised that although it worke every search field had to be filled in.

So I thought ( I know dangerous) that if i the code below I changed the AND to an OR it would allow a search based on either 1,2,3 or 4 of the criteria.

Wrong!!!

is there a "phrase" for AND/OR

thanks

Ian

Sign in to reply to this post

Jason ByrnesWebAssist

it should ignore form fields that are not filled in.

Can you send a copy of the page so I can see the code.

Sign in to reply to this post

i.edwards384429

files

Hi Jason

I've attached both the search and results pages.The unequal seach works perfectly.

There are 5 search fields.

the fist two, Name and type are a basic text search so that if someone wants to find a boat called "fred" just that boat is listed the same as a search for "catermaman" would just list boats of that type.

The three other fields are:

cost

berths and loa

all three of which now have a variance built in so the cost search is +/- 5000.

If I leave the first two fields blank they seem to be ignored but the last three appear to "required" because unless all three fields have a value no results are shown.

Thanks for the assist and have a good weekend

cheers

Ian

Attached Files
files.zip
Sign in to reply to this post

Jason ByrnesWebAssist

try changing:

php:
$WADbSearch1->addComparison("dt_Price","" . ($_GET['S_dt_Price']  -5000) .  "","AND",">=",1); $WADbSearch1->addComparison("dt_Price","" . ($_GET['S_dt_Price']  +5000) .  "","AND","<=",1);

  $WADbSearch1->addComparison("dt_loa","" . ($_GET['S_dt_loa']  -10) .  "","AND",">=",1); $WADbSearch1->addComparison("dt_loa","" . ($_GET['S_dt_loa']  +10) .  "","AND","<=",1);
  $WADbSearch1->addComparison("dt_berths","" . ($_GET['S_dt_berths']  -2) .  "","AND",">=",1); $WADbSearch1->addComparison("dt_berths","" . ($_GET['S_dt_berths']  +2) .  "","AND","<=",1);



to:

php:
$WADbSearch1->addComparison("dt_Price","" . isset($_GET['S_dt_Price'])?($_GET['S_dt_Price']  -5000):$_GET['S_dt_Price'] .  "","AND",">=",1); $WADbSearch1->addComparison("dt_Price","" . isset($_GET['S_dt_Price'])?($_GET['S_dt_Price']  +5000):$_GET['S_dt_Price'] .  "","AND","<=",1);

  $WADbSearch1->addComparison("dt_loa","" . isset($_GET['S_dt_loa'])?($_GET['S_dt_loa']  -10):$_GET['S_dt_loa'] .  "","AND",">=",1); $WADbSearch1->addComparison("dt_loa","" . isset($_GET['S_dt_loa'])?($_GET['S_dt_loa']  +10):$_GET['S_dt_loa'] .  "","AND","<=",1);
  $WADbSearch1->addComparison("dt_berths","" . isset($_GET['S_dt_berths'])?($_GET['S_dt_berths']  -2):$_GET['S_dt_berths'] .  "","AND",">=",1); $WADbSearch1->addComparison("dt_berths","" . isset($_GET['S_dt_berths'])?($_GET['S_dt_berths']  +2):$_GET['S_dt_berths'] .  "","AND","<=",1);
Sign in to reply to this post

i.edwards384429

update

Hi Jason

thanks for that, It seems to be a step in the right direction but I get the following when I run some test searches

search on price only I get no results

search on LOA only I get no results

search on berths only I get no results

search on LOA and Berths I get no results

search on price and berths I get no results

search on price and loa I get results

search on price, loa and berths I get results

I'm sure there is some logic there just at the moment I cant see it.

I'll get back on it on monday - busy today getting the house ready for visitng ghouls and ghosties tomorrow;-)

thanks

Ian

Sign in to reply to this post

Jason ByrnesWebAssist

ok, maybe try using this code instead:

php:
if(isset($_GET['S_dt_Price']) && $_GET['S_dt_Price'] != "") {

$WADbSearch1->addComparison("dt_Price","" . isset($_GET['S_dt_Price'])?($_GET['S_dt_Price']  -5000):$_GET['S_dt_Price'] .  "","AND",">=",1); $WADbSearch1->addComparison("dt_Price","" . isset($_GET['S_dt_Price'])?($_GET['S_dt_Price']  +5000):$_GET['S_dt_Price'] .  "","AND","<=",1);
}
if(isset($_GET['S_dt_loa']) && $_GET['S_dt_loa'] != "") {
  $WADbSearch1->addComparison("dt_loa","" . isset($_GET['S_dt_loa'])?($_GET['S_dt_loa']  -10):$_GET['S_dt_loa'] .  "","AND",">=",1); $WADbSearch1->addComparison("dt_loa","" . isset($_GET['S_dt_loa'])?($_GET['S_dt_loa']  +10):$_GET['S_dt_loa'] .  "","AND","<=",1);
}
if(isset($_GET['dt_berths']) && $_GET['dt_berths'] != "") {
  $WADbSearch1->addComparison("dt_berths","" . isset($_GET['S_dt_berths'])?($_GET['S_dt_berths']  -2):$_GET['S_dt_berths'] .  "","AND",">=",1); $WADbSearch1->addComparison("dt_berths","" . isset($_GET['S_dt_berths'])?($_GET['S_dt_berths']  +2):$_GET['S_dt_berths'] .  "","AND","<=",1); 
}
Sign in to reply to this post

i.edwards384429

update

Hi Jason

thanks for the assist works perfectly, now all I have to do is try to understand the code;-)

cheers

Ian

Sign in to reply to this post

Jason ByrnesWebAssist

i put an if statement around each comparison so it would only be added if the corresponding form element where set and not equal to a blank string:
if(isset($_GET['dt_berths']) && $_GET['dt_berths'] != "") {

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...