-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtotalKas.php
33 lines (24 loc) · 1.25 KB
/
totalKas.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: access');
header('Access-Control-Allow-Methods: GET');
header('Content-Type: application/json; charset=UTF-8');
header('Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With');
require_once __DIR__ . '/src/dbConnect.php';
require_once __DIR__ . '/src/jsonHandler.php';
if ($_SERVER['REQUEST_METHOD'] == 'GET') :
$sql = "SELECT SUM(agustus) as total_agustus, SUM(september) as total_september,SUM(oktober) as total_oktober,SUM(november) as total_november,SUM(desember) as total_desember FROM kas";
$query = mysqli_query($conn, $sql);
// $result = $conn->query($query);
// $array = array(); // define array
// while ($row = mysqli_fetch_array($query, MYSQLI_ASSOC)) {
// $array[] = $row; // Inside while loop
// }
// echo json_encode(array($array));
// jsonHandler(200,'',$array);
$row = mysqli_fetch_array($query, MYSQLI_ASSOC);
// $total_agustus = $row['total_agustus'];
// $total_september = $row['total_september'];
echo json_encode($row);
endif;
// jsonHandler(405, 'HTTP Methode dalam endpoint ini harus GET!');