-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrankingi_panstw.php
executable file
·118 lines (97 loc) · 4.45 KB
/
rankingi_panstw.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
session_start();
$_SESSION['back'] = "strona-glowna";
?>
<!DOCTYPE HTML>
<html lang="pl">
<meta charset="UTF-8"/>
<head>
<title>TempStats</title>
<meta name="descripion" content="Baza danych pomiarów temeratur"/>
<meta name="keywords" content="temperature, database, dataset, climat, changes"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<link rel="stylesheet" href="style.css" type="text/css"/>
<link rel="stylesheet" href="pola_wyboru.css" type="text/css"/>
<link href="https://fonts.googleapis.com/css?family=Lato:400,900&subset=latin-ext" rel="stylesheet">
</head>
<body>
<div id="wrapper">
<div id="logo">TempStats</div>
<div class="space_none"></div>
<?php echo file_get_contents("menu.php"); ?>
<div id="container">
<?php echo file_get_contents("topbar.php"); ?>
<?php echo file_get_contents("sidemenu.php"); ?>
<div id="content">
<span class="bigtitle">Ranking ciepłoty państw</span>
<div class="dottedline"></div>
<table class="table_standard">
<tbody>
<tr>
<th>Lp.</th>
<th>Państwo</th>
<th>Średnia temperatura</th>
</tr>
<?php
require_once "connect.php";
$conn = oci_connect($db_user, $db_password, $host);
if (!$conn) {
echo "oci_connect failed\n";
$e = oci_error();
echo $e['message'];
} else {
$q = '
SELECT Cou_name, avg(M.temp) avg_temp
FROM Measurment M,
(
SELECT C.name C_name,
C.id C_id,
Sub_name,
Cou_name
FROM City C,
(
SELECT Sub.name Sub_name,
Cou.name Cou_name,
Sub.id Sub_id,
Cou.id Cou_id
FROM Substate Sub
RIGHT JOIN Country Cou
ON Sub.country = Cou.id
)
WHERE C.substate = Sub_id
OR C.country = Cou_id
)
WHERE M.city_id = C_id
GROUP BY Cou_name
ORDER BY avg_temp';
$stmt = oci_parse($conn, $q);
oci_execute($stmt, OCI_NO_AUTO_COMMIT);
$no = 1;
while (($row = oci_fetch_array($stmt, OCI_BOTH))) {
echo '<tr>
<td>' . $no++ . '.</td>
<td>' . $row[COU_NAME] . '</td>
<td>' . round($row[AVG_TEMP], 3) . '</td>
</tr>';
}
}
?>
</tbody>
</table>
</div>
</div>
<?php echo file_get_contents("footer.php"); ?>
</div>
<div id="login">
<div id="login_content">
<?php
if (!isset($_SESSION['info_logowanie']))
$_SESSION['info_logowanie'] = "<a href='formularz-logowania'>Zaloguj się</a> lub <a href='formularz-rejestracji'>zarejestruj</a>";
echo $_SESSION['info_logowanie'];
?>
</div>
</div>
<script src="jquery-3.2.0.min.js"></script>
<script src="jquery.scrollTo.min.js"></script>
<script src="scripts.js"></script>
</body>