connect_error) { echo '

Connection failed

'; die("Connection failed: " . $conn->connect_error); } // Fetch last 48 records from the database $sql = "SELECT Time, Voltage FROM Info ORDER BY Time DESC LIMIT 48"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo "Time: " . $row["Time"]. " - Voltage: " . $row["Voltage"]. "
"; } } else { echo "0 results"; } $conn->close(); ?>