我正在尝试从Amazon RDS数据库中读取数据并打印出查询结果。但是,当我尝试在php中读取查询并打印结果时,它会打印实际代码而不是结果。有人可以帮帮我吗。这是我的代码。
<!DOCTYPE html>
<html><body><pre><code><?php
$host = "myhost";
$db = "database";
$user = "user";
$pass = "password";
$link = mysqli_connect($host,$user,$pass, $db);
$query = "SELECT * FROM my_project1.all";
$results = mysqli_query($link, $query);
if(mysqli_num_rows($result >=1)){
echo '<table class= "table table-striped table-bordered table-hover">';
echo "<tr><th>Name</th><th>City</th><th>State</th></tr>";
while($row = mysqli_fetch_array($result)){
echo "<tr><td>";
echo $row[0];
echo "</td><td>";
echo $row[1];
echo "</td><td>";
echo $row[2];
echo "</td></tr>";
}
echo "</table>";
}
else {
echo "There was no match found";
}
include 'index.php';
?></code></pre></body></html>
我将这个States.php文件调用到index.php中,代码如下
<nav id="navigation">
<ul id="nav">
<li><a href="States.php">States</a></li>
</ul>
</nav>
</section>