Created
October 3, 2013 07:25
-
-
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
This file contains hidden or 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
<?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