<?php // DB接続クラス読み込み require_once "../model/DbPdo.php"; // 画面から変数取得 $content = filter_input(INPUT_GET, "content"); $userID = filter_input(INPUT_GET, "userID"); $categoryID = filter_input(INPUT_GET, "categoryID"); // スレッド新規作成 $sql = "INSERT INTO threads(category_id, content, creater, created, updater) VALUES(" . "'" . $categoryID . "' , '" . $content . "' , '" . $userID . "' , now(), '" . $userID . "')"; $result = DbPdo::InsUpdDelPdo($sql); if (!$result) { exit('データを登録できませんでした。'); } // スレッド作成成功時、スレッドが紐づくカテゴリのスレッド数を取得 $sql_chk_category = "SELECT * FROM categories WHERE id = '" . $categoryID . "' AND del_flg = 0"; $result_chk_category = DbPdo::SelectPdo($sql_chk_category); if (!$result_chk_category) { exit('カテゴリ情報を取得できませんでした。'); } $cnt_comment = $result_chk_category['cnt_comment']; $cnt_comment++; // スレッド作成成功時、スレッドが紐づくカテゴリを更新 $sql_upd_category = "UPDATE categories SET cnt_comment = '" . $cnt_comment . "', updater = '" . $userID . "' WHERE id = '" . $categoryID . "'"; $result_upd_category = DbPdo::InsUpdDelPdo($sql_upd_category); if (!$result_upd_category) { exit('カテゴリを更新できませんでした。'); } ?> <p>登録が完了しました。<br /><a href="../view/dispThreads.php?userID=<?php echo $userID; ?>
<div style="height: 600px;"> <!-- 各スレッド一覧表示 --> <?php // 選択したカテゴリに紐づくスレッドの件数取得 $sql_all = "SELECT * FROM threads WHERE category_id = '" . $categoryID . "' AND del_flg = 0"; $cntThreads = DbPdo::CountPdo($sql_all); if ($cntThreads != 0) { // 選択したカテゴリに紐づくスレッドが存在する場合 // スレッド画面表示用 $sql = $sql_all; // ページャ条件を追加 if (isset($dispLimit)) { $offset = $dispLimit * ($dispPage - 1); $sql = $sql . " LIMIT " . $dispLimit . " OFFSET " . $offset; } $result = DbPdo::SelectPdo($sql); if (!$result) { exit('データを取得できませんでした。'); } // 表示上限ページ数 $max_page = ceil($cntThreads / $dispLimit); // 表示スレッド数 if ($cntThreads < $dispLimit) { $dispLimit = $cntThreads; } } ?> <!-- 上記で配列に格納した値を画面用に取り出す --> <?php for ($i = 0; $i < $dispLimit; $i++) {
public function GetUserID($mailAddress, $password) { $sql = "SELECT * FROM login_users WHERE address = " . "'" . $mailAddress . "'" . " AND password = "******"'" . $password . "'" . " AND del_flg = 0;"; $result = DbPdo::SelectPdo($sql); return $result[0]['id']; }