Creating search form

Discover how to use ChronoForms8 to create a search form on Joomla for a list of database table rows

flyboeing 05 Jun, 2025

Hi, 

I made a search form with a textfield. It is a simple form but it is working. The next step is to make it a form for a more advanced search, with dropdowns and checkboxes. 

I have the following WHERE statement:

reg LIKE {var.quote:search} OR airline LIKE {var.quote:search} OR type = {data.in:type}

The 'type' field is a checkbox with two values (Civil or Cargo).

As you can see the WHERE-statement only uses the OR-statement (for example: airline LIKE Delta OR type = Civil). But I would like to make different combinations. If multiple fields are used for searching, the only results that need to be shown are results that meet both criteria (for example: airline = LATAM and type = Cargo).

But how can I make that work?

Max_admin 08 Jun, 2025
Answer

Hi flyboeing

Do you know about the List Search behavior in ChronoForms v8:

Creating search form image 1

You can use it to setup the search conditions automatically

if this is not matching your requirements then you can use PHP in the Where Statement behavior to build the WHERE conditions or build it inside a PHP action and get it in the Where Statement box using {var:php_name}

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
flyboeing 12 Jun, 2025

Thank you Max. 

I made the following PHP action:

// Import Joomla's database classesuse Joomla\CMS\Factory;use Joomla\CMS\Table\Table;

// Get the database connection$db = Factory::getDbo();

// Create a new query object$query = $db->getQuery(true);

// Execute the query$db->setQuery("SELECT reg, aircraft, airline FROM c5x1d_regdatabase WHERE reg LIKE '%".$this->data['search']."%'");

// Load the results as an array of objects$results = $db->loadAssocList();

return  $results;

My form has the following fields:

  • text input for search
  • button for submitting
  • php action
  • table

But how can I connect the PHP action to the table so it shows results.

Max_admin 12 Jun, 2025

Like this:

Creating search form image 2

Replace php_name with the name of your PHP action

Another way to run a custom SQL code is:

Creating search form image 3

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
You need to login to be able to post a reply.