Files
2026-04-17 11:45:21 +02:00

56 lines
1.9 KiB
PHP

<!-- RICHIESTA FILA A -->
<?php
session_start();
include 'db_conf.php';
// Query per ottenere il tempo totale di utilizzo giornaliero aggregato per fascia d'età
$sql = "SELECT f.range_eta, SUM(s.ore_medie_giornaliere) AS ore_totali
FROM Statistiche_Dispositivi s
JOIN Fasce_Eta f ON f.id_fascia=s.id_fascia
GROUP BY f.id_fascia, f.range_eta
ORDER BY f.id_fascia ASC";
$resultDispositivi = $conn->query($sql);
// Interruzione in caso di errore nella richiesta
if ($resultDispositivi === false){
die("Errore nella query: " . $conn->error);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GenZ Digital Hub</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<?php if (isset($_SESSION['id'])): ?>
<h1>Benvenuto, <?php echo htmlspecialchars($_SESSION['name'] . ' ' . $_SESSION['surname']); ?>!</h1>
<p><a href="logout.php">Logout</a></p>
<hr>
<h2>Tempo Totale di Utilizzo Giornaliero per Fascia d'Età</h2>
<table border="1" cellpadding="10" cellspacing="0">
<thead>
<tr>
<th>Fascia d'Età</th>
<th>Ore Totali Giornaliere</th>
</tr>
</thead>
<tbody>
<?php while ($row = $resultDispositivi->fetch_assoc()): ?>
<tr>
<td><?php echo htmlspecialchars($row['range_eta']); ?></td>
<td><?php echo number_format($row['ore_totali'], 2, ',', '.'); ?> ore</td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
<?php else: ?>
<h1>Benvenuto su GenZ Digital Hub</h1>
<p><a href="login.php">Accedi</a> o <a href="register.php">Registrati</a> per visualizzare le statistiche.</p>
<?php endif; ?>
</body>
</html>