forked from ashleyjuan/DatabaseFinalProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcost.php
More file actions
22 lines (20 loc) · 645 Bytes
/
cost.php
File metadata and controls
22 lines (20 loc) · 645 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
include "index.php";
// fetch records
$sql = "SELECT `customer`.`name` , `customer`.`phone_number` , `customer`.`email` , SUM(`payment`.`fee`) AS cost
FROM `package`
LEFT JOIN `payment` ON `package`.`package_id`=`payment`.`package_id`
LEFT JOIN `customer` ON `payment`.`customer_id`=`customer`.`customer_id`
GROUP BY `payment`.`customer_id`
ORDER BY cost DESC";
$result = mysqli_query($con, $sql);
while ($row = mysqli_fetch_assoc($result)) {
$array[] = $row;
}
$dataset = array(
"echo" => 1,
"totalrecords" => count($array),
"totaldisplayrecords" => count($array),
"data" => $array
);
echo json_encode($dataset);