Buy Now
Sign in

Displaying table results based on Form data

jkrah , April 12 2015, 12:10
jkrah 15
April 12 2015, 12:10 #345846
I hope someone is willing to help me.
I have build a simple form with two fields. Year and Event ('Jaar' and 'Evenement' in Dutch).
When the Year is selected, a dynamic dropdown populates the Event field. This wors fine.
You can find it here

After submit I want to display the results from a table that I build in the Joomla db,

I tried Db Read Action (in the 'on submit' event, but I lack the knowledge on how to set that up properly.
I also tried in stead of the DB read a custom code action that displays the result from the table based on the selections made in the form, but the query is not picking up my {year} and {event} in the query:
I use this:
$result = mysqli_query($con,"SELECT * FROM bap_zk_achmea_uitslagen WHERE Jaar='{Jaar}' AND Evenement='{Evenement}' "); 

This gives the desired result:
$result = mysqli_query($con,"SELECT * FROM bap_zk_achmea_uitslagen WHERE Jaar='2013' AND Evenement='10 KM' ");

But the one with the variables does not seem to pick it up..
I am not a hero in PHP and searched the forum for hours for a solution but cannot find it.
I am sure it should be relatively easy, but I am running into a brick wall here.
Any suggestions/help are welcome.
calculus00 1
April 12 2015, 12:10 #345847
Hello jkrah,
I'm not a Chrono professional, but after checking your new post, I think that the following links may help:
How do I save form data to a database table?
How to load record data from a database table into your form
P.S: I'm just an automated service
I'm an automated service, my answers may help, but they may not be accurate.
jkrah 15
April 12 2015, 13:16 #345849
That is the other way round. I know how to save form data to a table and the second option is not what I am looking for
GreyHead 64
April 12 2015, 16:07 #345851
Hi jkrah,

You can't use the curly brackets syntax {Jaar} in PHP, Instead use $form->data['Jaar'] e.g.
" . . .WHERE `Jaar` = '{$form->data['Jaar']}' AND `Evenement`  = '{$form->data['Evenement']}'
which uses the different PHP curly brackets.

To use the DB Read action set the Table to point to your table and add a WHERE clause in the Conditions box like this
return array('Jaar' => $form->data['Jaar'], 'Evenement' => $form->data['Evenement']);
See this FAQ for more examples.

ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
jkrah 15
April 12 2015, 16:32 #345854
ah, you are amazing, Thanks it works!