-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetInfo.php
57 lines (53 loc) · 1.52 KB
/
getInfo.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
54
55
56
57
<?php
function getTotal($con){
$total = 0;
$query= "SELECT totPosti FROM parametri";
$result = mysqli_query($con, $query);
if (!$result){
die('Errore di query: '.mysqli_error($con));
} else {
$rows = mysqli_num_rows($result);
if ($rows!=1){
die('Errore parametri in db.');
}else{
$infos = mysqli_fetch_assoc($result);
$total = $infos['totPosti'];
}
}
return $total;
}
function getPrenotati($con){
$totPrenotati = 0;
$query= "SELECT count(*) as totPrenotati FROM prenotazioni WHERE stato = 'occupied'";
$result = mysqli_query($con, $query);
if (!$result){
die('Errore di query: '.mysqli_error($con));
} else {
$rows = mysqli_num_rows($result);
if ($rows!=1){
die('Errore parametri in db.');
}else{
$infos = mysqli_fetch_assoc($result);
$totPrenotati = $infos['totPrenotati'];
}
}
return $totPrenotati;
}
function getOccupati($con){
$totOccupati=0;
$query= "SELECT count(*) as totOccupati FROM prenotazioni WHERE stato = 'booked'";
$result = mysqli_query($con, $query);
if (!$result){
die('Errore di query: '.mysqli_error($con));
} else {
$rows = mysqli_num_rows($result);
if ($rows!=1){
die('Errore parametri in db.');
}else{
$infos = mysqli_fetch_assoc($result);
$totOccupati = $infos['totOccupati'];
}
}
return $totOccupati;
}
?>