-
Notifications
You must be signed in to change notification settings - Fork 0
/
getdata.php
executable file
·53 lines (44 loc) · 1.64 KB
/
getdata.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
$db=new SQLite3('cluster.db');
$tsql= "SELECT count(*) FROM clustel";
$bsql= "SELECT count(*) FROM clustel where TIPERUMAH='Sangat Sederhana'";
$ssql= "SELECT count(*) FROM clustel where TIPERUMAH='Sederhana'";
$gsql= "SELECT count(*) FROM clustel where TIPERUMAH='Menengah'";
$psql= "SELECT count(*) FROM clustel where TIPERUMAH='Mewah'";
$asql= "SELECT count(*) FROM clustel where TIPERUMAH='Apartemen'";
$result=$db->query($tsql);
$row = $result->fetchArray(SQLITE3_ASSOC);
$total = $row["count(*)"];
$result=$db->query($bsql);
$row = $result->fetchArray(SQLITE3_ASSOC);
$bronze = round($row["count(*)"],2);
$result=$db->query($ssql);
$row = $result->fetchArray(SQLITE3_ASSOC);
$silver = round($row["count(*)"],2);
$result=$db->query($gsql);
$row = $result->fetchArray(SQLITE3_ASSOC);
$gold = round($row["count(*)"],2);
$result=$db->query($psql);
$row = $result->fetchArray(SQLITE3_ASSOC);
$platinum = round($row["count(*)"],2);
$result=$db->query($asql);
$row = $result->fetchArray(SQLITE3_ASSOC);
$apartemen = round($row["count(*)"],2);
$blank=$total-($bronze+$silver+$gold+$platinum+$apartemen);
$blank=round($blank,2);
$data=array($bronze,$silver,$gold,$platinum,$apartemen,$blank);
// $bronzesql= "SELECT count(*) FROM clustel where TIPECLUSTER=/"sederhana/" ";
// $result=$db->query($bronzesql);
// $row = $result->fetchArray(SQLITE3_ASSOC);
// $bronze = $row["count(*)"];
// $final = json_decode($final, true);
// $new_final = array();
// // simple flattening
// foreach($final as $value) {
// foreach($value as $sub_value) {
// $new_final[] = $sub_value;
// }
// }
echo json_encode($data);
exit;
?>