-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e92b94a
commit 4f3df5a
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
$servername = "localhost"; | ||
$username = "username"; | ||
$password = "password"; | ||
$dbname = "myDB"; | ||
|
||
// Create connection | ||
$conn = new mysqli($servername, $username, $password, $dbname); | ||
// Check connection | ||
if ($conn->connect_error) { | ||
die("Connection failed: " . $conn->connect_error); | ||
} | ||
|
||
$sql = "SELECT id, firstname, lastname FROM MyGuests"; | ||
$result = $conn->query($sql); | ||
|
||
if ($result->num_rows > 0) { | ||
// output data of each row | ||
while($row = $result->fetch_assoc()) { | ||
echo "Time: " . $row["time"]. " - Temp: " . $row["temp"]. " humidity " . $row["humidity"]. "<br>"; | ||
} | ||
} else { | ||
echo "0 results"; | ||
} | ||
$conn->close(); | ||
?> |