【发布时间】:2020-10-14 01:16:05
【问题描述】:
输出数据时,以一行显示。如何确保每条记录都是一个对象,所有对象都变成一个数组?
<?php
require_once("db.php");
$query = $db->query('SELECT * FROM `dictdb`.`dictwords`');
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
echo "
id: " . $row['id'] . ",
engWord: " . $row['engwords'] . ",
rusWord: " . $row['ruswords'] ."
";
}
?>
test.js
$(document).ready(function () {
$(".btn-test").on("click", function () {
$.ajax({
url: "/src/php/tests.php",
type: "POST",
success: function (data) {
$(".test-word").html(data);
}
})
})
【问题讨论】:
标签: javascript php mysql arrays ajax