我想在html中顯示數據庫表。我有以下的PHP代碼,將得到表和在HTML表格格式返回,它有沒有錯誤:
功能觀察平面() {通過javascript在html中顯示數據庫表
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>";
}
在HTML文件中,我的JavaScript代碼如下調用PHP函數,也應該把它添加到div:
<script type="text/javascript">
$(document).ready(function(){
$("#menu_active").click(function(){
$("#table").after('<?php $test->viewplane(); ?>')
});
});
</script>
代碼:
<?php $test->viewplane(); ?>
WO當放在html之間時,爲什麼不工作?
什麼是生成的JavaScript是什麼樣子?什麼是JavaScript錯誤控制檯說的HTML。裏面事項? – Quentin
沒有錯誤,它只是不顯示任何東西。如果我替換代碼: viewplane(); ?>與它正常工作的字符串。 – gNazi