close ad
WARNING PC USERS: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Search Criteria set to AND or OR user preference

Thread began 12/31/2009 12:45 am by jo4koalas392067 | Last modified 1/08/2010 4:29 pm by Eric Mittman | 1440 views | 7 replies |

jo4koalas392067

Search Criteria set to AND or OR user preference

Hi
What I am trying to do is allow the user to set the search preference to either AND for all options or OR for all options. Do you know the best way to do this?
Possible Options:

1) Set up 2 DA Server Behaviours Searches on a results page 1 set to ANDs and 1 set to ORs- if so how do you do this and have it pick the right one when finding the results.

2) On Search Page radio button one set to choose AND and one set to OR and through coding all "comparison list additions" are updated to the appropriate AND or OR.

3) Put 2 buttons on the search form or something similar, one going to a results page that contains Server Behaviour DataAssist Search set to AND and the other to a second results page that contains Server Behaviour DA Search set to OR.

Not sure which option if any would work and if one of them does, have you any idea what code I should use?

Hope this makes sense.

I am using php, WA Super Suite on a local server XAMPP using MySQL and Apache.

Thanks Jo

Sign in to reply to this post

Eric Mittman

I think your best option for this would be to first craft one of the DataAssist Search server behaivor. Once it is crafted you can create another or duplicate the first one.

After crafting the search server behaviors you can use a radio group or have a checkbox to specify weather to use the ANDs or ORs. You can then go back to the results page and alter the triggers for the search server behaviors. For the first one you will add in a check for the value of the checkbox to see if it is set to the value specified in the value attribute of the checkbox.

For the second search on the page you will check to see if the posted checkbox does not have the value specified. These custom triggers might look like this:

php:
if(isset($_POST['check1']) && $_POST['check1'] == 'the value'){


the other search trigger

if( (isset($_POST['check1']) && $_POST['check1'] != 'the value') || !(isset($_POST['check1'])) || $_POST['check1'] != 'the value'){



This should give you both searches and one will be used over the other depending on the user selection.

Sign in to reply to this post

jo4koalas392067

Hi Eric

Thank you for your help and Happy New Year. I have tried to do what you are suggesting, but cannot get this to work - unfortunately php is new to me so I think it is my lack of knowledge not your suggestion which is the problem. I wonder if you could look at my code and let me where I am going wrong.

Thanks Jo

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

Eric Mittman

I took a look at the page and I think the problem may just be the placement of the if statements. Rather than trying to get the if statements in the correct location through trial and error it may be easier to just update the first DASearch server behavior that you have on the page. You can use a ternary expression to switch the 'OR' and 'AND' separators. In the page that you posted you could do this by changing lines 51-57 to be like this:

php:
$WADbSearch1->addComparisonFromEdit("StateOccVisaID","S_StateOccVisaID",(isset($_POST['All']) && $_POST['All'] == 'Yes')?"OR":"AND","=",1);

  $WADbSearch1->addComparisonFromEdit("ASCO","S_SOVOccupationID",(isset($_POST['All']) && $_POST['All'] == 'Yes')?"OR":"AND","Begins With",0);
  $WADbSearch1->addComparisonFromEdit("SOVStateID","S_SOVStateID",(isset($_POST['All']) && $_POST['All'] == 'Yes')?"OR":"AND","=",1);
  $WADbSearch1->addComparisonFromCheck("V176","176","Yes","",(isset($_POST['All']) && $_POST['All'] == 'Yes')?"OR":"AND","=","=",0);
  $WADbSearch1->addComparisonFromCheck("V886","886","Yes","",(isset($_POST['All']) && $_POST['All'] == 'Yes')?"OR":"AND","=","=",0);
  $WADbSearch1->addComparisonFromCheck("V475","475","Yes","",(isset($_POST['All']) && $_POST['All'] == 'Yes')?"OR":"AND","=","=",0);
  $WADbSearch1->addComparisonFromCheck("V487","487","Yes","",(isset($_POST['All']) && $_POST['All'] == 'Yes')?"OR":"AND","=","=",0);



What I did was replace the "OR" part of the original code with a check for the checkbox. If it is set and has a value of 'yes' then the expression will be true and "OR" will be used. If the expression is false then the "AND" will be used.

I think this is a simpler and easier method than using the if statements, sorry for not suggesting this way from the beginning. If you do it like this you can get rid of the second Search server behavior as well as your custom if statements. Please give this a try and let me know if you need any further help with it.

Sign in to reply to this post

jo4koalas392067

Hi Eric

Thank you for your response. Sorry for the delay in replying - just migrated my site from test local server to live site. Sadly I cannot get your suggestion to work as it gives the same results each time which is AND.

As I have now got it on a live site you can view it for yourself:
stateoccvisajoin_Results.php

If you need to login use:
username: test
password: test

Thanks Jo

Sign in to reply to this post

Eric Mittman

I think that the problem might be with the method of the search form. Rite now you have it set to get like this:

html:
<form id="WADASearchForm" name="WADASearchForm" method="get" action="stateoccvisajoin_Results.php">



I think if you updated the code to use the get then it should work for you. The code would look like this with the update:

php:
$WADbSearch1->addComparisonFromEdit("StateOccVisaID","S_StateOccVisaID",(isset($_GET['All']) && $_GET['All'] == 'Yes')?"OR":"AND","=",1);

  $WADbSearch1->addComparisonFromEdit("ASCO","S_SOVOccupationID",(isset($_GET['All']) && $_GET['All'] == 'Yes')?"OR":"AND","Begins With",0);
  $WADbSearch1->addComparisonFromEdit("SOVStateID","S_SOVStateID",(isset($_GET['All']) && $_GET['All'] == 'Yes')?"OR":"AND","=",1);
  $WADbSearch1->addComparisonFromCheck("V176","176","Yes","",(isset($_GET['All']) && $_GET['All'] == 'Yes')?"OR":"AND","=","=",0);
  $WADbSearch1->addComparisonFromCheck("V886","886","Yes","",(isset($_GET['All']) && $_GET['All'] == 'Yes')?"OR":"AND","=","=",0);
  $WADbSearch1->addComparisonFromCheck("V475","475","Yes","",(isset($_GET['All']) && $_GET['All'] == 'Yes')?"OR":"AND","=","=",0);
  $WADbSearch1->addComparisonFromCheck("V487","487","Yes","",(isset($_GET['All']) && $_GET['All'] == 'Yes')?"OR":"AND","=","=",0);



Please give this a try and let us know how this works for you.

Sign in to reply to this post

jo4koalas392067

It Worked!

Hi Eric

It worked, although the other way round than I was expecting. By checking the box we got the OR instead of the AND, but that is OK I have just amended the search page to specify "match any" when the check box is ticked.

Thank you so much for your help on this, I really appreciate it.

Jo

Sign in to reply to this post

Eric Mittman

Alright, that is good to hear. I'm glad it worked out for you, sorry about the backward result, I may have had the setup backward when I posted the updated code.

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...