Example #1
0
<?php

include_once 'include/header.php';
include_once 'include/helpers.php';
$bbcode = new Golonka\BBCode\BBCodeParser();
$topic = array();
$comments = array();
$result = $connection->query('SELECT * FROM topic WHERE id = ' . $connection->real_escape_string($_GET['id']) . ' ORDER BY id ASC;');
if ($result->num_rows > 0) {
    while ($row = $result->fetch_assoc()) {
        $topic[$row['id']] = $row;
        $topic[$row['id']]['content'] = $bbcode->parseCaseInsensitive($row['content']);
        $topic[$row['id']]['raw_content'] = javascript_escape($row['content']);
        $result2 = $connection->query('SELECT * FROM users WHERE id = ' . $row['author_id']);
        if ($result2->num_rows > 0) {
            while ($row2 = $result2->fetch_assoc()) {
                $topic[$row['id']]['author_name'] = $row2['name'];
                $topic[$row['id']]['author_name_safe'] = javascript_escape($row2['name']);
            }
        }
        $result2 = $connection->query('SELECT * FROM category WHERE id = ' . $row['category_id']);
        if ($result2->num_rows > 0) {
            while ($row2 = $result2->fetch_assoc()) {
                $topic[$row['id']]['category_name'] = $row2['name'];
            }
        }
        $result2 = $connection->query('SELECT * FROM comments WHERE topic_id = ' . $row['id']);
        if ($result2->num_rows > 0) {
            while ($row2 = $result2->fetch_assoc()) {
                $comments[$row2['id']] = $row2;
                $comments[$row2['id']]['content'] = $bbcode->parseCaseInsensitive(nl2br($row2['content']));