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

// Query to fetch data
$sql = "SELECT source_name, DATE_FORMAT(cdate, '%k:%i %p,%e %b %y') as created_date,source_code FROM tbl_lead_source";
$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()) {
        $data[] = [$sl, $row['source_name'], $row['source_code'], $row['created_date']];
		$sl++;
    }
}

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

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



?>
