1
0
mirror of https://github.com/Daichimarukana/uwuzu.git synced 2026-06-04 19:14:41 +00:00
Files
uwuzu-mirror/notice/notice.php
T
だいちまる 9ede52e05e Version 1.2.5
2023-08-19 17:49:56 +09:00

41 lines
1.1 KiB
PHP

<?php
//------------------------------------------
// データベースに接続
try {
$option = array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::MYSQL_ATTR_MULTI_STATEMENTS => false
);
$pdo = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $option);
} catch(PDOException $e) {
// 接続エラーのときエラー内容を取得する
$error_message[] = $e->getMessage();
}
$sql = "SELECT title, note, account, datetime FROM notice ORDER BY datetime DESC";
$notice_array = $pdo->query($sql);
while ($row = $notice_array->fetch(PDO::FETCH_ASSOC)) {
$notices[] = $row;
}
if(!empty($notices)){
foreach ($notices as $value) {
$uneinoticenote = htmlentities($value['note']);
$uneinoticetitle = htmlentities($value['title']);
$uneinoticeaccount = htmlentities($value['account']);
$uneinoticedatetime = htmlentities($value['datetime']);
}
}else{
$uneinoticenote = "";
$uneinoticetitle = "おしらせはありません";
$uneinoticeaccount = "uwuzu";
$uneinoticedatetime = "";
}