logo

Shellblock

简单实现PHP读取数据库

2021-01-15 Views152字1 min read
featureimg
<?php
$server = "localhost";
$username = "root";
$password = "123456";
$dbname = "db";
$mysqli = new mysqli ($server, $username, $password, $dbname);

$result = mysqli_query ($mysqli, "select * from account");
echo "<table border = '1px'>";
echo "<caption><b>账号列表</b></caption>";
echo "<tr><th>用户名</th><th>密码</th><th>邮箱</th></tr>";
while ($r = mysqli_fetch_object ($result)){
	echo "<tr><td>" . $r->username . "</td><td>" . $r->password . "</td><td>" . $r->email ."</td></tr>";
}
echo "</table>";
mysqli_fetch_object ($result);
mysqli_close ($mysqli);
?>

mysqli_fetch_object

EOF