게시판관리 - 테이블생성 목록만들기

이태현·2025년 8월 19일

Web 개발

목록 보기
25/53
post-thumbnail

게시판 Table - DB 등록

CREATE TABLE board_manage(
idx INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
`name` VARCHAR(255) DEFAULT '' COMMENT '게시판 이름',
`bcode` VARCHAR(40) DEFAULT '',
`btype` ENUM('board','gallery') DEFAULT 'board' COMMENT '게시판 타입',
`cnt` INTEGER DEFAULT 0 COMMENT '게시물 수',
`create_at` DATETIME
);

게시판 Table - Result

게시판 - UI

  <?php

  $g_title = "해커들의 놀이터";

  $menu_code = "board";

  include "inc_common.php";
  include "inc_header.php";
  include "../inc/dbconfig.php";
  include "../inc/board.php"; // 게시판 관리 Class

  $board = new Board($db);

  $boardArr = $board->list();

  ?>
  <main class="border rounded-2 p-5 " style="height: calc(100vh - 265px);">

    <div class="container">
      <h3 class="">게시판관리</h3>
    </div>

    <table class="table table-border">
      <tr>
        <th>번호</th>
        <th>게시판 이름</th>
        <th>게시판 코드</th>
        <th>게시판 타입</th>
        <th>게시물 수</th>
        <th>등록일시</th>
        <th>관리</th>
      </tr>
      <?php
      foreach ($boardArr as $row) {
      ?>
        <tr>
          <td><?= $row["idx"]; ?></td>
          <td><?= $row["name"]; ?></td>
          <td><?= $row["bcode"]; ?></td>
          <td><?= $row["btype"]; ?></td>
          <td><?= $row["cnt"]; ?></td>
          <td><?= $row["create_at"]; ?></td>
          <td>
            <button class="btn btn-primary btn-sm btn_mem_edit" data-idx="<?= $row["idx"]; ?>">수정</button>
            <button class="btn btn-danger btn-sm btn_mem_delete" data-idx="<?= $row["idx"]; ?>">삭제</button>
          </td>
        </tr>
      <?php
      }
      ?>
    </table>

    <button class="btn btn-primary">게시판 작성</button>

  </main>

  <?php
  include "inc_footer.php";
  ?>

마무리

다음 시간에는 게시판 생성, 모달 창, 스크립트 작업을 해보겠습니다.

감사합니다.

profile
이해하고 분석하고 지배한다

0개의 댓글