<html>
<head>
<title> 浏览数据库中的记录</title>
<head>
<center>
<?php
error_reporting(0);
$link = mysqli_connect(
'localhost', /* The host to connect to 连接MySQL地址 */
'root', /* The user to connect as 连接MySQL用户名 */
'root', /* The password to use 连接MySQL密码 */
'sys'); /* The default database to query 连接数据库名称*/
if (!$link) {
printf("Can't connect to MySQL Server. Errorcode: %s ", mysqli_connect_error());
exit;
}
$result = mysqli_query($link, 'SELECT * FROM sys_config');
echo "当前表中的记录有:";
echo "<table border=1>";
echo "<tr><td>Variable</td><td>Value</td><td>Set_time</td></tr>";
/* Fetch the results of the query 返回查询的结果 */
while( $row = mysqli_fetch_assoc($result) ){
//printf("%s | %s | %s", $row['variable'], $row['value'], $row ['set_time']);
echo "<tr>";
echo "<td>".$row[variable]."</td>";
echo "<td>".$row[value]."</td>";
echo "<td>".$row[set_time]."</td>";
echo "</tr>";
}
echo "</table>";
/* Destroy the result set and free the memory used for it 结束查询释放内存 */
mysqli_free_result($result);
mysqli_close($link);
?>
</center>
</body>
</html>
PHP与MySQL数据库连接
最新推荐文章于 2017-08-11 12:42:10 发布