Skip to content

Commit

Permalink
php info
Browse files Browse the repository at this point in the history
  • Loading branch information
markzeidan committed Aug 9, 2016
1 parent e92b94a commit 4f3df5a
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions php_mysql.php
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();
?>

0 comments on commit 4f3df5a

Please sign in to comment.