<table>
  <th>
  <div id="center_button">
  <button onclick="location.href='dashboard.php'"> Painel de controle </button>
  </div>
  </th>
</table>

<?php

$username='miguelde_modulo4';
$password='modulo4';
$dbname='miguelde_modulo4';
$host='localhost';

echo 
'

<h3> Site de Lais e Thais - Listagem de Leituras</h3>
<table border=2>
<tr>
<td>ID Leitura</td>
<td>Placa MAC</td>
<td>Nome placa</td>
<td>Data leitura</td>
<td>Hora Leitura</td>
<td>Valor</td>
</tr>

';


try {
 $conn = new PDO("mysql:host=$host;dbname=$dbname", $username, $password);
 $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
 $sql='SELECT leitura.idleitura,
 leitura.mac_idmac,
 mac.nome,
 leitura.dataleitura,
 leitura.horaleitura,
 leitura.valor
 from leitura, mac
 where leitura.mac_idmac=mac.idmac ';
 $data = $conn->query($sql);
 foreach($data as $row) {
 echo'<td>'.($row[0]).'</td>';
 echo'<td>'.($row[1]).'</td>';
 echo'<td>'.($row[2]).'</td>';
 echo'<td>'.($row[3]).'</td>';
 echo'<td>'.($row[4]).'</td>';
 echo'<td>'.($row[5]).'</td><tr>';
 }echo'</table>';
} catch(PDOException $e) {
 echo 'ERROR: ' . $e->getMessage();
}
 ?>
  <th>
            <div id="center_button">
            <button onclick="location.href='dashboard.php">voltar</button>
</th>   