<?php
header('Content-Type: application/json');
include 'db/db_connect.php';
$companyfk = $_REQUEST['companyfk'];
$query = mysqli_query($con, "SELECT * FROM buses_tb where companyfk = '$companyfk'");
$data = array();
$qry_array = array();
$i = 0;
$total = mysqli_num_rows($query);
while ($row = mysqli_fetch_array($query)) {
  $data['busid'] = $row['busid'];
  $data['companyfk'] = $row['companyfk'];
  $data['number_plate'] = $row['number_plate'];
  $data['seats'] = $row['seats'];
  $qry_array[$i] = $data;
  $i++;
}
if($query){
  $response['success'] = 'true';
  $response['message'] = 'Data Loaded Successfully';
  $response['total'] = $total;
  $response['data'] = $qry_array;
}else{
  $response['success'] = 'false';
  $response['message'] = 'Data Loading Failed';
}
echo json_encode($response);
?>
