To get data from database into Custom Files, basically v2022 is same with v2021.
You may try this from demo2022 project, by creating a new Custom File, for example, with the following settings:
- File Name: getemployees.php
- Caption: Get Employees
- Include common files: enabled
Code: Select all
<?php
$sql = "SELECT `FirstName`, `LastName` FROM `employees`"; // define your SQL
$stmt = ExecuteQuery($sql); // execute the query
$displayResult = ""; // initial display result
if ($stmt->rowCount() > 0) { // check condition: if record count is greater than 0
while ($row = $stmt->fetch()) { // begin of loop
$displayResult .= $row["FirstName"] . " " . $row["LastName"] . "<br>"; // in case the result returns more than one row, separated by line break
} // end of loop
echo "Here is the Employees list: <br>" . $displayResult; // display the result
} else { // if there are no result
echo "No records are found."; // display the message
} // end of check condition
?>