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

// Set header to return JSON
header('Content-Type: application/json');

// Query to fetch all projects
$query = "SELECT tbl_project_id as id, tbl_project_name as name FROM tbl_project WHERE tbl_project_flag = 0 ORDER BY tbl_project_name ASC";
$result = $conn->query($query);

$projects = [];

if ($result && $result->num_rows > 0) {
    while ($row = $result->fetch_assoc()) {
        $projects[] = [
            'id' => $row['id'],
            'name' => $row['name']
        ];
    }
}

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

$conn->close();
?> 