<?php
include('dbconnect.php');
include('function.php');

// Query to fetch data
$sql = "SELECT tbl_project_id, tbl_project_name, tbl_project_code, tbl_project_address,tbl_project_api_url, tbl_project_location,tbl_project_flag,DATE_FORMAT(tbl_project_cdate, '%k:%i %p, %d %b %y') as created_date FROM tbl_project";
$result = $conn->query($sql);

$data = [];
if ($result->num_rows > 0) {
    // Fetch the data and store it in an array
	$sl=1;
    while ($row = $result->fetch_assoc()) {
		$city_name=get_city_name($row['tbl_project_location']);
        $data[] = [$sl, $row['tbl_project_name'], $row['tbl_project_code'],$city_name, $row['tbl_project_address'],$row['tbl_project_api_url'], $row['created_date'],$row['tbl_project_flag']];
		$sl++;
    }
}

// Close the database connection
$conn->close();

// Return the data as JSON
echo json_encode($data);



?>
