【发布时间】:2020-01-09 16:41:18
【问题描述】:
我正在尝试将数据库显示到 html 页面中。数据出现在我的控制台中,但我不知道如何在 html 表中显示它。我不确定我需要添加到console.log(数据)中以使其显示到页面上的功能。这是我目前所拥有的:
<button class="btn btn-primary" id="btn">Get Code</button>
<table class="table table-bordered">
<thread>
<tr>
<th>ID</th>
<th>City</th>
<th>Country</th>
<th>Rating</th>
</tr>
</thread>
<tbody id ="tdata">
</tbody>
</table>
<script>
$(function () {
$.getJSON("php.php", {tableName:"travel"}, function(data){
if (data["code"] == "error"){
console.log(data["message"]);
}
else{
console.log(data);
}
console.log("returned hh");
});
});
console.log("returned");
</script>
</body>
</html>
【问题讨论】:
-
PHPMyAdmin 不是数据库。它是 MySQL 数据库的 Web 界面。
-
您需要共享您的 PHP 代码,该代码正在从数据库中获取数据。
-
Java 不是 Javascript,它们是不同的。
-
我删除了错误的标签。这里没有 Java 代码,phpMyAdmin 是一个工具而不是数据库。
-
我正在尝试使用 jquery 来获取 MySQL 数据库