본문 바로가기

PHP16

[p-book] admin alt text-delete '', 'alt' => '',]; // Initialize image array$errors = [ 'alt' => '', 'warning' => '',]; // Initialize error messageif ($id) { // If valid article id $sql = "SELECT i.id, i.file, i.alt FROM image AS i JOIN.. 2024. 6. 28.
[p-book] admin image-delete fetch(); // Get image data}if (!$image) { // If no image redirect('article.php', ['id' => $id]); // Redirect}$path = '../uploads/' . $image['file']; // Path to fileif ($_SERVER['REQUEST_METHOD'] == 'POST') { // If form was submitted $sql = "UPDATE article SET image_id = null WHERE id = :art.. 2024. 6. 28.
[p-book] admin article-delete 'Article not found']); // Redirect with error}$article = false; // Initialize article$sql = "SELECT a.title, a.image_id, i.file AS image_file FROM article AS a LEFT JOIN image AS i ON a.image_id = i.id WHERE a.id = :id;"; // SQL to get article data$article = pdo($pdo, $sql,.. 2024. 6. 28.
[p-book] admin article id 없을때 id 있을때  $id, 'title' => '', 'summary' => '', 'content' => '', 'member_id' => 0, 'category_id' => 0, 'image_id' => null, 'published' => false, 'image_file' => '', 'image_alt' => '',]; // Article data$errors = [ 'warning' => '', 'title' => '', 'summary' .. 2024. 6. 28.
[p-book] admin articles fetchAll(); // Get article summaries?> Articles Add new article ImageTitleCreatedPublishedEditDelete " alt=""> " class="btn btn-primary">Edit " class="btn btn-danger">Delete 2024. 6. 28.
[p-book] admin category-delete 'Category not found']); // Redirect with error}$sql = "SELECT name FROM category WHERE id = :id;"; // SQL to get category name$category = pdo($pdo, $sql, [$id])->fetchColumn(); // Get category nameif (!$category) { // If no category redirect('categories.php', ['failure' => 'Category not found']); // Redirect with error}if ($_SERVER['REQUEST.. 2024. 6. 28.
[p-book] admin category $id, 'name' => '', 'description' => '', 'navigation' => false,]; // Initialize category array$errors = [ 'warning' => '', 'name' => '', 'description' => '',]; // Initialize errors array// If there was an id, page is editing the category, so get curren.. 2024. 6. 28.
[p-book] admin categories fetchAll(); // Get all categories?> Categories Add new category Name Edit Delete " class="btn btn-primary">Edit " class="btn btn-danger">Delete 2024. 6. 28.
[p-book] admin index fetchColumn(); // Get number of articles$sql = "SELECT count(id) FROM category"; // SQL$category_count = pdo($pdo, $sql)->fetchColumn(); // Get number of categories?> Admin CountCreateView Categories Add View Articles Add View 2024. 6. 28.
[p-book] header Skip to content Menu " > Search  document.body.classList.add('js');var toggle = document.querySelector('#toggle-navigation');var menu = document.querySelector('#menu');var menuItems = document.querySelectorAll('#menu li a');toggle.a.. 2024. 6. 28.
[p-book] search fetchColumn(); // Return count if ($count > 0) { // If articles match term $arguments['show'] = $show; // Add to array for pagination $arguments['from'] = $from; // Add to array for pagination $sql = "SELECT a.id, a.title, a.summary, a.category_id, a.member_id, c.name .. 2024. 6. 28.
[p-book] member fetch(); // Get member dataif (!$member) { // If array is empty include 'page-not-found.php'; // Page not found}$sql = "SELECT a.id, a.title, a.summary, a.category_id, a.member_id, c.name AS category, CONCAT(m.forename, ' ', m.surname) AS author, i.file AS ima.. 2024. 6. 28.