~~~
<?php
include 'config.php'; //将config.php中的内容插入到inc.php
// 创建连接
$conn=mysqli_connect(DB_HOST,DB_DBUSER,DB_DBPASS,DB_DBNAME);
// 检查连接
if (!$conn)
{
die("连接错误: " . mysqli_connect_error());
}else{
//连接成功后要执行的代码
$sql = "";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// 输出数据
while($row = $result->fetch_assoc()) {
echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "<br>";
}
} else {
echo "0 结果";
}
//$conn->close(); 关闭数据库
}
?>
~~~