forked from if-itb/IF3110-01-Simple-Blog
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_comment.php
More file actions
25 lines (20 loc) · 779 Bytes
/
get_comment.php
File metadata and controls
25 lines (20 loc) · 779 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
include 'sql_my.php';
if (!isset($_GET['id'])) {
echo "wrong GET";
} else {
$mysqli = new mysqli("localhost", "WBD_USER", "QKC3zwhJ", "WBD_DB");
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
} else {
if (!($result = $mysqli->query("SELECT * FROM `comments` WHERE `ID_POST` = ".$_GET['id']." ORDER BY `ID` DESC"))) {
echo "Query failed: (" . $mysqli->errno . ") " > $mysqli->error;
} else {
while ($row = $result->fetch_row()) {
echo '<li>' .
'<h2>'. htmlspecialchars($row[2]) .'</h2>' .
time_passed($row[5]) .
'<p>'. htmlspecialchars($row[4]) .'</p>' .
'</li>';
}}}}
?>