示例来自w3schools:
http://www.w3schools.com/php/php_mysql_select.asp
$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");
echo "
Firstname | Lastname |
---|
while($row = mysqli_fetch_array($result))
{
echo "
";echo "
" . $row['FirstName'] . "";echo "
" . $row['LastName'] . "";echo "
";}
echo "
";mysqli_close($con);
?>
这是一个学习的好地方