Hi all,
For my website I am creating a search form with multiple fields. These are text boxes, drop down menus and radiobuttons.
I am having problem getting the results displayed. When I search for a registration, I get all the registrations from my database as if no search criteria has applied.
This is what I have in the "preview" tab:

This is what I have in the "Event" tab:

As you can see I have in the On Submit a DBMRL with the following settings:
Basic
Table: movements_ewas
Request Param: var_success
Model ID: movements_ewas
Advanced
Load Data: Yes
WHERE statement:
In the On Empty Result I have a custom code with a text if there are no records found and a 'show stopper' (got that one from the DBMRL tutorial).
The following custom code is loaded after the DBMRL:
So when I am going to test my form I get all the reg and type from my database (in a list) and below that there is my debugger telling me the following thing:

How can I get my search form to work?
Regards,
Ruud
PS. Using Joomla 2.5 and CFv4
For my website I am creating a search form with multiple fields. These are text boxes, drop down menus and radiobuttons.
I am having problem getting the results displayed. When I search for a registration, I get all the registrations from my database as if no search criteria has applied.
This is what I have in the "preview" tab:

This is what I have in the "Event" tab:

As you can see I have in the On Submit a DBMRL with the following settings:
Basic
Table: movements_ewas
Request Param: var_success
Model ID: movements_ewas
Advanced
Load Data: Yes
WHERE statement:
'reg' LIKE '%<?php echo $form->data['reg']; ?>%' OR 'type' LIKE '%<?php echo $form->data['type']; ?>%' OR 'status' LIKE '%<?php echo $form->data['status']; ?>%'
In the On Empty Result I have a custom code with a text if there are no records found and a 'show stopper' (got that one from the DBMRL tutorial).
The following custom code is loaded after the DBMRL:
<table>
<?php
foreach($form->data['movements_ewas'] as $search):
?>
</tr>
<td>Reg:<?php echo $search['reg']; ?></td>
<td>Type:<?php echo $search['type']; ?></td>
</tr>
<?php
endforeach;
?>
</table>
So when I am going to test my form I get all the reg and type from my database (in a list) and below that there is my debugger telling me the following thing:

How can I get my search form to work?
Regards,
Ruud
PS. Using Joomla 2.5 and CFv4
Are you sure that $form->data['type'] exists?
If your code results in OR 'type' LIKE '%%' it will return every record.
Rob
If your code results in OR 'type' LIKE '%%' it will return every record.
Rob
The form->data['type'] refers to the 'type' input field. That input field has a name called 'type'. Maybe I am doing something wrong.
I thought that if I use 'OR' that it will look for reg OR type, not both. Is there a way to fix this? So When I fill in just one field in my form that it will show those results.
I thought that if I use 'OR' that it will look for reg OR type, not both. Is there a way to fix this? So When I fill in just one field in my form that it will show those results.
I also found out that my WHERE-query has to be changed:
I removed the '' before the like (so not 'reg', but reg).
When I remove the rest of the query, so I only have reg LIKE '%<?php echo $form->data['reg']; ?>%', my search works.
But how does it work if you have more search criteria?
'reg' LIKE '%<?php echo $form->data['reg']; ?>%' OR 'type' LIKE '%<?php echo $form->data['type']; ?>%' OR 'status' LIKE '%<?php echo $form->data['status']; ?>%'
I removed the '' before the like (so not 'reg', but reg).
When I remove the rest of the query, so I only have reg LIKE '%<?php echo $form->data['reg']; ?>%', my search works.
But how does it work if you have more search criteria?
The form->data['type'] refers to the 'type' input field. That input field has a name called 'type'. Maybe I am doing something wrong.
I thought that if I use 'OR' that it will look for reg OR type, not both. Is there a way to fix this? So When I fill in just one field in my form that it will show those results.
The value of the input field gets in the Form data array when the form is submitted before that $form->data['type'] will be empty.
Also the query is run when the table data is loaded.
For dynamic filters you will need javascript, not PHP.
The OR checks both conditions, if one or both are true OR is true.
If you want to check if ony one is true the syntax is AND NOT or XOR
Rob
This topic is locked and no more replies can be posted.