23 lines
No EOL
630 B
PHP
23 lines
No EOL
630 B
PHP
<?php
|
|
include "./lib/config.php";
|
|
include "./lib/mysql.php";
|
|
include "./lib/getGravatar.php";
|
|
|
|
$article = $conn->real_escape_string($_GET["article"]);
|
|
|
|
$responseJSON = [];
|
|
|
|
$result = $conn->query("SELECT * FROM comments WHERE article='$article'");
|
|
if ($result->num_rows > 0) {
|
|
while ($row = $result->fetch_assoc()) {
|
|
$commentElement = [
|
|
"name" => $row["name"],
|
|
"comment" => $row["comment"],
|
|
"gravatarURL" => get_gravatar($row["email"])
|
|
];
|
|
|
|
array_push($responseJSON, $commentElement);
|
|
}
|
|
}
|
|
header('Content-Type: application/json');
|
|
echo json_encode($responseJSON); |