When outputting data, they are displayed in one line. How to make sure that every record is an object and all objects turn into an array?
<?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);
}
})
})