I am trying to create a datatable in Moodle. However, I have problem fetching data from the database and putting the data into the datatable. Can someone help me? Here is my index.php
<?php
require_once '../../config.php';
global $USER, $DB,$CFG;
$PAGE->set_url('/local/glossary/index.php');
$PAGE->set_context(context_system::instance());
$PAGE->requires->jquery();
//$PAGE->requires->js('/local/glossary/assets/glossary.js');
require_login();
$strpagetitle=get_string('glossary','local_glossary');
$strpageheading=get_string('glossary','local_glossary');
$PAGE->set_title($strpagetitle);
$PAGE->set_heading($strpageheading);
$sql = "SELECT id, term, definition FROM mdl_local_glossary";
$result = $DB->get_records_sql($sql);
$result = new stdClass();
echo $OUTPUT->header();
echo $OUTPUT->render_from_template('local_glossary/searchbar',[]);
echo $OUTPUT->footer();