Display Data From a Given Database Table

bc bcrod 18 Dec, 2014
Hi,

Just started using Chronoforms and been struggling in the past days to show all data from a given table on a form.

In "Setup" I drag a "DB Reader" to the "On Load" Event, but can't seem to find the way to show the data I'm retrieving from DB.

Can anyone give me a detailed HOWTO?


Regards,
Bruno
Gr GreyHead 18 Dec, 2014
Hi Bruno,

In ChronoForms v5 there is no built in data lister action. You can do it using PHP in a Custom Code Element in your form if you need to. The easier solution is to use ChronoConnectivity which is designed as a data lister. Please see the FAQs for a starter tutorial.

Bob
bc bcrod 18 Dec, 2014
Thanks for the fast reply Bob.

Any tutorial with Custom PHP Code example?

Meanwhile, I'll try ChronoConnectivity.


Regards,
Bruno
Gr GreyHead 19 Dec, 2014
1 Likes
Hi Bruno,

In a ChronoForms Custom code element use a PHP foreach loop to cycle through your data and display a table row each time. So if your data is in $form->data['my_data'] and you have columns 'id' and 'name' it would be something like this:
<?php
echo '<table>
  <tr><th>ID</th><th>Name</th></tr>';
foreach ( $form->data['my_data'] as $d ) {
  echo "<tr><td>{$d['id']}</td><td>{$d['name']}</td></tr>";
}
echo '</table>';
?>
Of course you can add more formatting and more columns as needed.
bc bcrod 19 Dec, 2014
Once again, thanks a lot for your help.
kr krotec 13 Jan, 2015
1 Likes
Thank you so much Bob after 3 days of going mad I figured out all that i was doing wrong from your snippet

Regards
Kevin
This topic is locked and no more replies can be posted.