Here is an example if that helps
- I have created a blank application
- created a php function and called this function from OnExecute event
The following is the content of the php function under Programming PHP methods
header(‘Access-Control-Allow-Origin: *’);
header(‘Content-Type: application/json’);
$data_arr = array();
$data_arr[‘data’] = array();
$check_sql = ‘SELECT categoryid, categoryname’
. ’ FROM categories’;
sc_select(rs, $check_sql);
if (false == {rs})
{
echo json_encode(array(‘message’ => ‘Error while accessing database.’));
}
else
{
while(!$rs->EOF)
{
$id = $rs->fields[0];
$categoryname = $rs->fields[1];
$post_item = array(
‘id’ => $id,
‘category’ => $categoryname
);
array_push ($data_arr[‘data’], $post_item);
$rs->MoveNext();
}
$rs->Close();
echo json_encode($data_arr);
}