Here is the content of my Custom File (with Include common files enabled):
<?php
$sql = "SELECT * FROM `mydata`"; // define your SQL
$stmt = ExecuteQuery($sql); // execute the query
?>
<table class="table table-sm table-hover table-striped table-bordered table-responsive-sm" id="myCustomData">
<thead>
<tr>
<th style="color: inherit;" scope="col" width="20">ID</th>
<th style="color: inherit;" scope="col" width="250">Description</th>
<th style="color: inherit;" scope="col" width="100">Date Created</th>
<th style="color: inherit;" scope="col" width="100">Date Updated</th>
</tr>
</thead>
<tbody>
<?php
if ($stmt->rowCount() > 0) { // check condition: if record count is greater than 0
while ($row = $stmt->fetchAssociative()) { // loop
?>
<tr>
<td><?php echo $row["ID"]; ?></td>
<td><?php echo $row["Description"]; ?></td>
<td><?php echo $row["DateCreated"]; ?></td>
<td><?php echo $row["DateUpdated"]; ?></td>
</tr>
<?php
} // end loop
?>
</tbody>
<tfoot>
</tfoot>
</table>
<?php
} else { // if there are no result
echo "No record found."; // display the message
} // end of check condition
?>
Here is the code to display the link to open that Custom File via Modal dialog:
<?php
echo '<a style="display: flex;float: left;" class="btn btn-xs btn-link ew-row-link ew-view" data-table="mydata" data-caption="My Custom Data" data-ew-action="modal" data-action="view" data-ajax="false" data-url="datatables" data-btn="null" data-bs-original-title="My Custom Data"><i data-phrase="ViewLink" class="icon-view ew-icon"><span class="visually-hidden">My Custom Data</span></i></a>';
?>
In case you want to reproduce it, here is the table schema including some records example in it:
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for mydata
-- ----------------------------
DROP TABLE IF EXISTS `mydata`;
CREATE TABLE `mydata` (
`ID` int NOT NULL AUTO_INCREMENT,
`Description` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`DateCreated` datetime NULL DEFAULT NULL,
`DateUpdated` datetime NULL DEFAULT NULL,
PRIMARY KEY (`ID`) USING BTREE
) ENGINE = MyISAM AUTO_INCREMENT = 13 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of mydata
-- ----------------------------
INSERT INTO `mydata` VALUES (1, 'First Row', '2025-05-29 20:27:11', '2025-06-01 10:41:41');
INSERT INTO `mydata` VALUES (2, 'Second Row', '2025-05-29 20:27:18', '2025-05-29 20:27:21');
INSERT INTO `mydata` VALUES (3, 'Third Row', '2025-05-29 20:27:23', '2025-05-29 20:27:26');
INSERT INTO `mydata` VALUES (4, 'Fourth Row', '2025-05-29 20:27:28', '2025-05-29 20:27:32');
INSERT INTO `mydata` VALUES (5, 'Fifth Row', '2025-05-29 20:27:34', '2025-05-29 20:27:37');
INSERT INTO `mydata` VALUES (6, 'Sixth Row', '2025-05-29 21:03:38', '2025-05-29 21:03:42');
INSERT INTO `mydata` VALUES (7, 'Seventh Row', '2025-05-29 21:03:44', '2025-05-29 21:03:47');
INSERT INTO `mydata` VALUES (8, 'Eights Row', '2025-05-29 21:03:49', '2025-05-29 21:03:52');
INSERT INTO `mydata` VALUES (9, 'Nineth Row', '2025-05-29 21:03:53', '2025-05-29 21:03:57');
INSERT INTO `mydata` VALUES (10, 'Tenth Row', '2025-05-29 21:03:59', '2025-05-29 21:04:01');
INSERT INTO `mydata` VALUES (11, 'Eleventh Row', '2025-05-29 21:04:05', '2025-05-29 21:04:10');
INSERT INTO `mydata` VALUES (12, 'Twelveth Row', '2025-05-29 21:04:13', '2025-05-29 21:04:20');
SET FOREIGN_KEY_CHECKS = 1;