Skip to content

Instantly share code, notes, and snippets.

@phamquocbuu
Created October 3, 2013 07:25
Show Gist options
  • Save phamquocbuu/6806316 to your computer and use it in GitHub Desktop.
Save phamquocbuu/6806316 to your computer and use it in GitHub Desktop.
PHP connect and get data From http://w3schools.com/php/php_mysql_select.asp
<?php
$con=mysqli_connect("example.com","peter","abc123","my_db");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM Persons");
while($row = mysqli_fetch_array($result))
{
echo $row['FirstName'] . " " . $row['LastName'];
echo "<br>";
}
mysqli_close($con);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment