Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Hi there,

I have built a search form which allows browsers to search for courses using any of the following fields:

Course Name

Starting Date

Presenter

Venue

Stream

I know that PHP searches default to "AND" and only records containing all criteria will be found unless otherwise specified.

I also know that you can add a line of code to change the search to an "OR" search as follows:

$InstanceName->AddDBParam('-lop', 'or');

But what I want is for the browser (person) to be able to select AND or OR in a drop-down list in the online search form so that the PHP script processes the search request based on their choice. So I need some kind of IF statement in the PHP code.

Does anyone know how to code this?

All replies received with thanks.

Steven

Do you want to mix AND and OR in the same query or just offer the possibility to either do AND or do OR queries?

The first is not possible solely with one query to the WPE (it does not allow mixing of OR/AND). This is an old restraint since the FileMaker CDML days, which still has not been resolved by FMI. You would have to send separate queries to the WPE, and then combine the results later with PHP or XSLT (Apache Xalan, the XSLT processor used by FMSA, offers set extension functions like difference or intersection for acting on XML result tree fragments).

For the latter, there should be a PHP solution (unfortunately, I don't know FX.php , but there will be an expert of this forum around who can answer this question, .e.g. Stephen Knight from FMWebSchool).

I will jump in for Martin on the PHP and the second option he states.

If you just want the user to be able to choose AND/OR you can simply write your IF statement into your PHP query.


$operator = $_POST['operator']

//This is the name of your and/or choice field in the form



$query = new FX($serverIP,$webCompanionPort);

$query -> SetDBData('databaseName','layout','groupSize');

$query -> SetDBPassword('password,'username');

//Your if check can now go here to see if the OR choice was made. If AND was chosen no problems

if ($operator == "OR") {

   $query -> AddDBParam('-lop', 'or');

}

$query -> AddDBParam('fieldName','formValuesHere');

//Add all your search fields here

$queryResult = $query->FMFind();



//Rest of page goes here

  • Author

Thanks andygaunt for your reply. That's exactly what I needed. Thanks also Martin for the heads up on AND/OR but my browsers will choose one or the other when they do a search.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.