prepare('SELECT * FROM article WHERE article_id = ?'); $stmt->bind_param('i', $article_id); $stmt->execute(); $article = $stmt->get_result()->fetch_assoc(); $stmt = $conn->prepare('SELECT tag_id FROM article_tags WHERE article_id = ?'); $stmt->bind_param('i', $article_id); $stmt->execute(); $result = $stmt->get_result(); $tags = []; while ($row = $result->fetch_assoc()) $tags[] = $row['tag_id']; $title = $article['title']; $excerpt = $article['excerpt']; $existing_markdown = read_file_one_string($_ENV['ARTICLES_FQ_PATH'] . $article_id . '/article.md'); } echo '
'; if (!empty($existing_markdown)) { echo form($article_id, $title, $excerpt, $existing_markdown, $tags); } else { echo form(); } echo preview(); echo '
'; include_once 'components/foot.php'; function form($article_id = null, $title = null, $excerpt = null, $existing_markdown = null, $tags = null) { $raw_tags = article_tags(); $tags_boxes = '
'; foreach ($raw_tags as $row) { $tags_boxes .= ' '; } $tags_boxes .= '
'; $form = '
' . (isset($article_id) ? '' : '') . ' ' . $tags_boxes . '
'; return $form; } function preview() { $preview = '
'; return $preview; }