- Tue Nov 26, 2019 10:43 pm
#827017
Hi,
I would like to populate a GRID with data from a database.
The GRID form detail is as follows:
Please assist.
Thank you.
I would like to populate a GRID with data from a database.
The GRID form detail is as follows:
Code: Select all
Below is my sample data:
ID : exchangeRateGrid
Field 1 id : ID type: textbox
Field 2 id : date type: date
Field 3 id : from_currency type: dropdown value & text : 3-character currency code
Field 4 id : to_currency type: dropdown value & text : 3-character currency code
Field 5 id : rate type: textbox
Code: Select all
Here is my trigger code:
Table Name : PMT_FOREX
+----+------------+---------------+-------------+-------------+
| ID | EDATE | FROM_CURRENCY | TO_CURRENCY | ERATE |
+----+------------+---------------+-------------+-------------+
| 1 | 2019-11-26 | ABC | DEF | 0.326382000 |
| 2 | 2019-11-26 | DEF | ABC | 3.063900000 |
+----+------------+---------------+-------------+-------------+
Note : FROM_CURRENCY & TO_CURRENCY are 3-character currency code
Code: Select all
With the above, I only manage to populate Field 1 (ID). I am very sure that I have missed something here.$dbConnection = 'workflow'; //set to ID of the DB Connection if using an external DB
$tableName = 'PMT_FOREX'; //set to table name
$sql = " SELECT * FROM $tableName WHERE 1 ORDER BY ID ASC";
$result = executeQuery($sql, $dbConnection);
@@exchangeRateGrid = array();
$idx = 0;
foreach ($result as $row){
++$idx;
@@exchangeRateGrid[$idx]['ID'] = $row['ID'];
@@exchangeRateGrid[$idx]['date'] = $row['edate'];
@@exchangeRateGrid[$idx]['from_currency'] = $row['from_currency'];
@@exchangeRateGrid[$idx]['to_currency'] = $row['to_currency'];
@@exchangeRateGrid[$idx]['rate'] = $row['erate'];
}
Please assist.
Thank you.