我试图从 DIV 中的 mysql 表中回显该行但不起作用,如果我输入:
echo $row['test'];
在里面while( $row = $result->fetch_assoc() ){
}
它工作得很好,但我希望它显示在 DIV 标签内。我知道我错过了一些东西,但不知道它是什么。谢谢你的帮助。
<?php
$mydb = new mysqli('localhost', 'root', '', 'test');
$sql = "SELECT * FROM test order by id limit 1 ";
$result = $mydb->query($sql);
if (!$result) {
echo $mydb->error;
}
while( $row = $result->fetch_assoc() ){
}
$mydb->close ();
?>
<html>
<head>
</head>
<body>
<div><? echo $row['test'];?>
</div>