I am trying to display a database table in html. I have the following php code that will get the table and return in an html table format and it has no errors:
function viewPlane()
{
if(!$this->DBLogin())
{
$this->HandleError("Database login failed!");
return false;
}
$qry = "select * from airplane";
$result = mysql_query($qry,$this->connection);
echo "<table border='1'>
<tr>
<th>Registration Number</th>
<th>Model Number</th>
</tr>";
while($row=mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['Registration_Number'] . "</td>";
echo "<td>" . $row['Model_Number'] . "</td>";
echo "</tr>";
}
echo "</table>";
}
In the html file, I have the following javascript code that calls the php function and Supposedly adds it to the div:
<script type="text/javascript">
$(document).ready(function(){
$("#menu_active").click(function(){
$("#table").after('<?php $test->viewplane(); ?>')
});
});
</script>
The code:
<?php $test->viewplane(); ?>
works when put among the html, so why is not working ?