I am trying to read the data from Amazon RDS database and print out the result of the query. However when I try to read the query in php and print the result it prints the actual code instead of the the result. Can someone please help me. Here is my code.
<!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>
And I am calling this States.php file into index.php with the following code
<nav id="navigation">
<ul id="nav">
<li><a href="States.php">States</a></li>
</ul>
</nav>
</section>