CasperSecurity
<?php
session_start();
include '../../connection/connection.php';
$db_handle= new DBController();
$select=$db_handle->runQuery("SELECT * FROM location ");
$db_handle = new DBController();
$selecthnum=$db_handle-> numRows("SELECT * FROM location ");
$last_row = $selecthnum - 1;
if($selecthnum >= 1){
echo '{"status": "1",
"data":[';
$i =1;
foreach($select as $resulth){
$a1 = $resulth['location_id'];
$a3 = $resulth['room_no'].'-'.$resulth['location_name'].'-'.$resulth['floor'].'-'.$resulth['building'];
echo'
{
"location_id":"'.$a1.'",
"location_name":"'.$a3.'"
}';
if($i <= $last_row){
echo ',';
}
$i++;
}
echo'
]}';
}else{
echo '{"status": "0",
"message":"Page Not found"
}';
}
?>