Show all results from select filter

I have a recordset that filters on select form field value. It works great.

But what I would like to do is to show all records by default. Right now the recordset is empty and I would like to show all records if no option is selected from the select field. So if nothing is selected in the Select Office field it should show all records.

Set your first select option value to value="" and use the condition option in the query builder to check if your $_GET.select_input

As a @Teodor says you want to have a condition in the query we actually solved this before quite a while ago so i will drop that thread here for reference:

Seems to be more than one way to do this. All I did have my first select option as value="" and then set the query to contains instead of equal.

Just put the condition in a new group and use the condition for it :slight_smile:

1 Like

Contains will work in some areas depending on the query for example

What if you had some offices called:
ace
landing space

Using ace as a filter here would return records for both offices, so it may work in certain areas but the conditions are better to prevent issues like this

Personally I would use the group with a condition

1 Like

Ah, good point. I will try and figure out how to use conditions.

Do you have an example of a screenshot of what that should look like? I’m really struggling to figure out this conditions thing.

This is what I have but it doesn’t work … still returns zero results unless office has a value.

Never tried this with a empty string I had a word value like published or all for example but maybe you could try:

{{$_GET.office != ""}} or {{$_GET.office != null}}

My method was in the select setting the first value to say all then the condition was {{$_GET.office != 'all'}}

It may make no difference but just a test if the empty string is the issue :slight_smile:

I don’t think the condition is being added to the SQL at all.

WHERE p_instances.inst_programid = 22 AND 
p_instances.inst_status = :P1 /* {{$_GET.status}} */ AND 
c_clients.client_office = :P2 /* {{$_GET.office}} */

Brad, it has always worked like that:

This works … on the live site. But it does’t work when you run the query in the query manager.

Thanks @Teodor! I learned something new. :beers: