Forums

Display all selected records from external database

CyborgPrime 08 Dec, 2016
I have a database of award recommendations that holds a person's name and award they are being recommended for.

I want to display selected records from an external database based on the award_name I select form a drop down.

I am able to dynamically populate the dropdown and send the selected award name to a second page for display, but I'm not sure what to do next.

Do I write a custom code that accesses the external database, or can i just use db read with multirecord to get all the records with the selected award name then use custom code to display them.

Or is there some other way that's easier?
GreyHead 09 Dec, 2016
Hi CyborgPrime,

The CFv5 DB Read action has an External Database tab - you could use that to read the records, then display then using a Custom Code element in the Designer tab to build a table.

Or you could use ChronoConnectivity - that also has an External Database tab.

Bob
CyborgPrime 09 Dec, 2016
I think I got it working up to the point where it gets all the records from the external database, I wasnt sure what to do next.

So now I just write some php custom code on page 2 in the designer that accesses the returned array and formats it for display?

Can do! I think.
GreyHead 09 Dec, 2016
Hi CyborgPrime,

That's it. Just a foreach loop through the data should do it
<?php
echo '<table>
  <thead>
    <tr>
      <th>aaa</th>
      . . . 
    </tr>
  </thead>
  <tbody>';
foreach ( $form->data['model_id'] as $v ) {
  echo "
   <tr>
    <td>{$v['aaa']}</td>
    . . .
  </tr>  ";
} 
echo '
  </tbody>
</table>';
?>

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