我在PHP服务器上使用一个简单的网站来打印表格中的一系列数据,但当我打开它时,打印 {$ row ['tempLog']} <而不是打印数据/ strong>等问题出在哪里:\
connect.php
<?php
function Connection(){
$connection = new mysqli("localhost", "root", "EasyMon", "test");
if ($connection->connect_errno)
{
echo "Failed to connect to MySQL: (" . $connection->connect_errno . ") " . $connection->connect_error;
}
echo $connection->host_info . "\n";
return $connection;
}
?>
这里是index.php网站:
<?php
include("connect.php");
$link=Connection();
$result=mysqli_query($link,"SELECT * FROM `Tabella1` ORDER BY `tempLog`");
?>
<html>
<head>
<title>Dati</title>
</head>
<body>
<h1>Potenziometro e sensore</h1>
<table border="1" cellspacing="1" cellpadding="1">
<tr>
<td> Timestamp </td>
<td> Temperature </td>
<td> Moisture </td>
</tr>
<?php
if($result!==FALSE){
while($row = mysqli_fetch_array($result)) {
echo ("<tr><td>{$row['tempLog']}</td><td>{$row['potenza']}</td><td>{$row['sensore']}</td></tr>");
}
mysqli_free_result($result);
mysqli_close($link);
}
?>
</table>
</body>
</html>