close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Help with search

Thread began 3/07/2014 12:57 pm by iainmacdonald331081 | Last modified 3/12/2014 4:40 pm by Jason Byrnes | 637 views | 18 replies |

iainmacdonald331081

Help with search

This might need to be a paid ticket, but am posting here first as it is hopefully not too far off working.

I have a db structure:

Tables:

Itineraries
ItineraryID (PK)
Itinerary
etc

Activities
ActivityID (PK)
Activity
etc

ItineraryActivities
ItineraryID
ActivityID

I am trying to create a search page where people can fill in some standard search fields, and also drill down by checking boxes to return itineraries that have particular activities associated with them.

I have gotten as far as the search with the text fields all working, and the search page is displaying all the activities along with the check boxes.

The search as it currently works will return results where any of the checked activities are a match.

http://www.safaribookers.com/search101/search101.php

What I can't seem to get is where it will return results where all of the checked activities are a match.

I have attached copies of the search and results page - if anyone could have a quick look and point me in the right direction that would be much appreciated.

Thanks.

Sign in to reply to this post

Jason ByrnesWebAssist

add the checkbox to your search form and set it to pass the activity ID as the value.

on the results page, go to bindings, click the plus button and select Form Data, then select the search form to add the search bindings to the results page.

in the data assist saerch behavior, set the Activity Criteria to use the Key Word search type. Set the OR seperator to use a coma followed by a space ", "

for the search value, click the lightning bolt icon and select the activity checkout box

Now, on the search form, edit the name of the activity check box to add "[]" at the end. This will create an array of the activity selections.

on the results page, add the following code to convert the array to a comma separated list:

<?php if(isset($_POST['activities'])) $_POST['activities'] = implode(", ", $_POST['activities']); ?>

the example above assumes the activities checkbox is named activities, if you use a different name, adjust accordingly.

Sign in to reply to this post

iainmacdonald331081

Thanks Jason.

Haven't been able to get too much further.

Is the checkbox not already on the search page passing ActivityID (the lines 136-141)?

On the results page, when I go to add the search form I only see an option to select a page, rather than a form?

And when I click on the DA Search Behaviour I get prompted to insert a recordset to use DA.

Sign in to reply to this post

Jason ByrnesWebAssist

you have hand coding in place that is breaking the ability to use the behavior.

on the update page,

change:

$KeyArr1 = array("Itinerary");



to:

$KeyArr1 = array("Itinerary");
$KeyArr2 = array("ActivityID");



and change:

$WADbSearch1->addComparisonFromList("ActivityID","Activity","AND","=",0);



to:

$WADbSearch1->keywordComparison($KeyArr2,"".((isset($_POST["Activity"]))?$_POST["Activity"]:"")  ."","AND","Includes",",%20","%20","%22","%22",0);





and add this code at line 1:

<?php if(isset($_POST['Activity'])) $_POST['Activity'] = implode(", ", $_POST['Activity']); ?>
Sign in to reply to this post

iainmacdonald331081

Thanks Jason,

I'd been trying something along those lines as well, but without any luck.

With the above there's something not quite right - with one checkbox ticked it works, but if you select more than one it draws a blank:

http://www.safaribookers.com/search101/search501.php

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

Jason ByrnesWebAssist

you're welcome.

Sign in to reply to this post

Jason ByrnesWebAssist

i made 2 changes to fix the problem.

i changed line 1 to:
<?php if(isset($_POST['Activity'])) $_POST['Activity'] = implode(",", $_POST['Activity']); ?>

and line 33 to:
$WADbSearch1->keywordComparison($KeyArr2,"".((isset($_POST["Activity"]))?$_POST["Activity"]:"") ."","AND","=","%20",",","%22","%22",0);

Sign in to reply to this post

iainmacdonald331081

Thanks Jason - still not working unfortunately. That's returning results with any of the checkboxes ticked.

Sign in to reply to this post

Jason ByrnesWebAssist

try this change:
line 1 to:
<?php if(isset($_POST['Activity'])) $_POST['Activity'] = implode(" ", $_POST['Activity']); ?>

and line 33 to:
$WADbSearch1->keywordComparison($KeyArr2,"".((isset($_POST["Activity"]))?$_POST["Activity"]:"") ."","AND","=",",%20","%20","%22","%22",0);

Sign in to reply to this post

iainmacdonald331081

Sorry Jason - still returning results matching any of the checkboxes ticked.

Sign in to reply to this post
loading

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