<?php
include 'connection.php';
$array = array();  
  
if (isset($_GET['cat_id'])) {
    if(is_numeric($_GET['cat_id']))
    $query = "SELECT * FROM status where cat_id='".$_GET['cat_id']."' order by position";
    else
    $query = "SELECT * FROM status order by position";
}
else{
$query = "SELECT * FROM status order by position";
}
$result = mysqli_query($mysqli , $query);  
while($row = mysqli_fetch_assoc($result))  
{  
    $array[] = $row;  
    }  
    echo json_encode($array)

?>