read only specific data

How to filter database results using a form field value in ChronoForms.

Overview

The issue occurs when incorrectly formatting PHP code to pass a form field value into a WHERE condition.
Use the correct PHP syntax to insert the form value into the condition array, ensuring the variable is properly concatenated within the string.

Answered
az azz13 07 Apr, 2014
It is posible use sql to read data by criteria like WHERE statement in version4
Gr GreyHead 07 Apr, 2014
Hi azz13,

Please see this FAQ I think that the Conditions Box in the DB Read action uses the same syntax.

Bob
az azz13 07 Apr, 2014
I use this sintax building WHERE statement

<?php
return array("model.field LIKE" => "%value%");
?>

If i write specific value all works great, but if I try read value from form this not work
Gr GreyHead 17 Apr, 2014
Hi azz13,

Where and how are you getting a value from the form?

Bob
az azz13 23 Apr, 2014
Hi
I try explain.
I have table with two columns "name" "groups".
For example record Mike group1,group4

Want to create form to filter group users. Create form with combobox with groups and submit button. Add "DB read" action to summit and add condition:
<?php return array('details.user_groups LIKE' => '%echo $form->data['search_group']%'); ?>

where user_groups is table field and search_group form field name. I see all results in table.

If i use

<?php return array('details.user_groups LIKE' => '%group3%'); ?>

all works great.

I use $form->data['search_group'] in custom code and all work great.

what am I doing wrong?
Gr GreyHead 23 Apr, 2014
Answer
Hi azz13,

You've got some serious problems with your PHP. This may work better:
<?php
return array('details.user_groups LIKE' => "%{$form->data['search_group']}%");
?>

Bob
az azz13 23 Apr, 2014
Hi Bob,

its now working just as I need .
Thank you for help!
This topic is locked and no more replies can be posted.