Skip to content

Instantly share code, notes, and snippets.

@pkarlink
Created March 16, 2016 15:22
Show Gist options
  • Save pkarlink/0a0f3fed55a1125c4a32 to your computer and use it in GitHub Desktop.
Save pkarlink/0a0f3fed55a1125c4a32 to your computer and use it in GitHub Desktop.
<?php
$servername = "db4free.net";
$username = "dbase000";
$password = "4eb81c";
$dbname = "dbase000";
// 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 "id: " . $row["aa"]. " - Name: " . $row["name"]. " " . $row["continent"]. "<br>";
}
} else {
echo "0 results";
}
$conn->close();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment