Posted in JSON, PHP, SQL

MySQL – Retrieving data for EasyUI datagrid

<?php

require_once($_SERVER[‘DOCUMENT_ROOT’].’/xxx/db/MysqliDb.php’);

// — Define containers ——————————————————-

$terugvoer = array();
$tmp = array();

// — Retrieve the list of questions by DEPARTMENT —————————–

$sql = “SELECT _DATE, _TIME, _USERID, _NAME, _ACTIVITY FROM audit”;

$db = new MysqliDb(‘CES’);

$selectStatus = $db->rawQuery($sql);

if ($selectStatus > 0) {

$tmp[‘message’] = ‘Central evaluation system – Questions loaded successfully’;
$tmp[‘success’] = ‘Y’;

foreach ($selectStatus as $row) {

$tmp[‘_DATE’] = $row[‘_DATE’];
$tmp[‘_TIME’] = $row[‘_TIME’];

$tmp[‘_USERID’] = $row[‘_USERID’];
$tmp[‘_NAME’] = $row[‘_NAME’];

$tmp[‘_ACTIVITY’] = $row[‘_ACTIVITY’];

$terugvoer[] = $tmp; 

}

}

echo json_encode($terugvoer);

?>