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.

Grouping Search Clauses with PHP

Featured Replies

  • Newbies

Hi there,

I'm trying to create a web page that searches multiple fields and returns a list of employees matching the search. Our database contains an archive of employees identified as terminated by a numeric field "Terminated". Basically I'm trying to see how one would go about achieving this SQL statement:

SELECT * FROM employees WHERE (firstname LIKE '%searchValue%' OR lastname LIKE '%searchvalue%' OR program LIKE '%searchvalue%' OR department LIKE '%searchvalue%') AND Terminated = 0

As there doesn't seem to be a way to add the necessary parentheses using FX for PHP, I tried adding the parameters in two ways as follows:

Try 1:

$EmpDB->AddDBParam('First Name',$theSearch,'cn');

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

$EmpDB->AddDBParam('Last Name',$theSearch,'cn');

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

$EmpDB->AddDBParam('Department',$theSearch,'cn');

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

$EmpDB->AddDBParam('Program',$theSearch,'cn');

$EmpDB->AddDBParam('Terminated','0','eq');

Try 2:

$EmpDB->AddDBParam('First Name',$theSearch,'cn');

$EmpDB->AddDBParam('Terminated','0','eq');

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

$EmpDB->AddDBParam('Last Name',$theSearch,'cn');

$EmpDB->AddDBParam('Terminated','0','eq');

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

$EmpDB->AddDBParam('Department',$theSearch,'cn');

$EmpDB->AddDBParam('Terminated','0','eq');

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

$EmpDB->AddDBParam('Program',$theSearch,'cn');

$EmpDB->AddDBParam('Terminated','0','eq');

Neither one of which worked because there is no way to force the logic that is required here. At this point I feel like I'm up a creek and missing my paddle. Anyone ever run into this?

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.