Article Image
Design In The Age Of AI: How to adapt fairly.

In this article, you’ll learn how to adapt your visual tone and skills to a new era where AI is changing almost everything...

Avatar Anonymous AI No • April 6, 2025
design ai creative
Article Image
Design In The Age Of AI: How to adapt fairly.

In this article, you’ll learn how to adapt your visual tone and skills to a new era where AI is changing almost everything...

Avatar Anonymous AI No • April 6, 2025
design ai creative
Article Image
Design In The Age Of AI: How to adapt fairly.

In this article, you’ll learn how to adapt your visual tone and skills to a new era where AI is changing almost everything...

Avatar Anonymous AI No • April 6, 2025
design ai creative
Blog image
2026-08-08 09:08:53
PHP Register 登録機能 CRUD パート1

.accordion-002 { max-width: 100%; margin-bottom: 3px; border: 1px solid #2589d0; ...

Read more
Blog image
2026-06-30 00:20:57
jQuery AJAXとPHPを組み合わせたページネーションと検索
Read more
Blog image
2026-06-26 22:08:31
jQuery AJAXとPHPを組み合わせたページネーション
Read more

PHP

Blog image
PHP Register 登録機能 CRUD パート1
PHP
ユーザー登録

.accordion-002 { max-width: 100%; margin-bottom: 3px; border: 1px solid #2589d0; border-radius: 5px; } .accordion-002 summary { display: flex; justify-content: space-between; align-items: center; position: relative; padding: 1em 2em; background-image: url('data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2028%2028%22%3E%0A%20%20%20%20%3Ccircle%20cx%3D%2214%22%20cy%3D%2214%22%20r%3D%2214%22%20style%3D%22fill%3A%232589d0%3B%22%2F%3E%0A%3C%2Fsvg%3E'); background-position: right calc(2em - 7px) center; background-size: 22px; background-repeat: no-repeat; color: #2589d0; font-weight: 600; cursor: pointer; } .accordion-002 summary::-webkit-details-marker { display: none; } .accordion-002 summary::before, .accordion-002 summary::after { position: absolute; right: calc(2em + 2.5px); width: 3px; height: 10px; border-radius: 5px; background-color: #fff; content: ''; } .accordion-002 summary::before { rotate: 90deg; } .accordion-002 summary::after { transition: rotate .3s; } .accordion-002[open] summary::after { rotate: 90deg; } .accordion-002 p { transform: translateY(-10px); opacity: 0; margin: 0; padding: 0 2em 1.5em; color: #333333; transition: transform .5s, opacity .5s; } .accordion-002[open] p { transform: none; opacity: 1; } index.php <?php session_start(); $token = bin2hex(random_bytes(32)); $_SESSION["srf_token"] = $token; ?> <!DOCTYPE html> <html lang="ja"> <head> <title>Bootstrap 5 Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js"></script> <style> .error-txt { color: #ff0000; /* 赤色などに指定 */ } </style> </head> <body> <div class="container-fluid p-5 bg-primary text-white text-center"> <h1>ユーザー登録とログイン</h1> </div> <div class="container mt-5"> <div class="row"> <div class="col-lg-6 offset-lg-3" id="alert"> <div class="alert"> <strong id="result"> </strong> </div> </div> </div> <div class="row"> <div class="col-lg-6 offset-lg-3 rounded p-4 shadow" id="register-box"> <!-- CSRFトークンの埋め込み --> <h2 class="text-center">新規登録</h2> <form action="" method="post" class="p-2" id="register-frm"> <input type="hidden" name="csrf_token" value="<?php echo htmlspecialchars($token, ENT_QUOTES, "UTF-8"); ?>"> <div class="form-group"> <label for="name" class="form-label">フルネーム</label> <input type="text" class="form-control" id="name" name="name" placeholder="フルネームを入力" value=""> </div> <div class="form-group"> <label for="uname" class="form-label">ユーザー名</label> <input type="text" class="form-control" id="uname" name="uname" placeholder="ユーザー名を入力"> </div> <div class="form-group"> <label for="email" class="form-label">Eメールアドレス</label> <input type="email" class="form-control" id="email" name="email" placeholder="Eメールアドレスを入力"> </div> <div class="form-group"> <label for="pass" class="form-label">パスワード</label> <input type="password" class="form-control" id="pass" name="pass" placeholder="パスワードを入力"> </div> <div class="form-group"> <label for="cpass" class="form-label">パスワードの確認</label> <input type="password" class="form-control" id="cpass" name="cpass" placeholder="パスワードを再入力"> </div> <div class="form-group"> <div class="custom-control custom-checkbox"> <label class="custom-control-label" for="customcheck2">利用規約に同意する</label> <input type="checkbox" class="custom-control-input" id="customcheck" name="customcheck" value="<?php if(isset($_COOKIE["username"])){ ?> checkd <?php } ?>"> </div> </div> <div class="form-group text-center"> <button type="submit" class="btn btn-primary" value="Register" id="register" name="register">新規登録</button> </div> <div class="form-group text-center mt-3"> <p class="">すでにアカウントをお持ちの場合は<a href="#" id="login-btn">ログインする</a></p> </div> </form> </div> </div> </div> <script src="https://code.jquery.com/jquery-4.0.0.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/jquery-validation@1.19.5/dist/jquery.validate.js"></script> <script> $(document).ready(function() { $("#alert").hide(); $("#register-frm").validate({ errorClass: "error-txt", errorElement: "p", rules: { name: { required: true, minlength: 5, }, uname: { required: true, minlength: 5, }, email: { required: true, email: true }, pass: { required: true, minlength: 6, }, cpass: { required: true, equalTo: "#pass" }, customcheck: { required: true, } }, messages: { name: { required: "フルネームを入力してください", minlength: "フルネームは5文字以上である必要があります" }, uname: { required: "ユーザー名を入力してください", minlength: "ユーザー名は5文字以上である必要があります" }, email: { required: "Eメールアドレスを入力してください", email: "有効なEメールアドレスを入力してください" }, pass: { required: "パスワードを入力してください", minlength: "パスワードは6文字以上である必要があります" }, cpass: { required: "パスワードの確認を入力してください", equalTo: "パスワードが一致しません" }, customcheck: { required: "同意に選択されていません", }, }, }); $("#register").click(function(e) { if ($("#register-frm").valid()) { e.preventDefault(); $("#loader").show(); $.ajax({ url: "action2.php", type: "POST", data: $("#register-frm").serialize() + "&action=register", success: function(response) { // レスポンスを処理するコードをここに追加 $("#alert").show(); $("#result").html(response); } }); } return true; }); }); </script> </body> </html> search.php <!DOCTYPE html> <html lang="en"> <head> <title>Page Title</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> * { box-sizing: border-box; } /* Style the body */ body { font-family: Arial, Helvetica, sans-serif; margin: 0; } /* Header/logo Title */ .header { padding: 80px; text-align: center; background: #1abc9c; color: white; } /* Increase the font size of the heading */ .header h1 { font-size: 40px; } /* Style the top navigation bar */ .navbar { overflow: hidden; background-color: #333; } /* Style the navigation bar links */ .navbar a { float: left; display: block; color: white; text-align: center; padding: 14px 20px; text-decoration: none; } /* Right-aligned link */ .navbar a.right { float: right; } /* Change color on hover */ .navbar a:hover { background-color: #ddd; color: black; } /* Column container */ .row { display: -ms-flexbox; /* IE10 */ display: flex; -ms-flex-wrap: wrap; /* IE10 */ flex-wrap: wrap; } /* Create two unequal columns that sits next to each other */ /* Sidebar/left column */ .side { -ms-flex: 30%; /* IE10 */ flex: 30%; background-color: #f1f1f1; padding: 20px; } /* Main column */ .main { -ms-flex: 70%; /* IE10 */ flex: 70%; background-color: white; padding: 20px; } /* Fake image, just for this example */ .fakeimg { background-color: #aaa; width: 100%; padding: 20px; } /* Footer */ .footer { padding: 20px; text-align: center; background: #ddd; } /* Responsive layout - when the screen is less than 700px wide, make the two columns stack on top of each other instead of next to each other */ @media screen and (max-width: 700px) { .row { flex-direction: column; } } /* Responsive layout - when the screen is less than 400px wide, make the navigation links stack on top of each other instead of next to each other */ @media screen and (max-width: 400px) { .navbar a { float: none; width: 100%; } } </style> </head> <body> <div class="header"> <h1>My Website</h1> <p>A website created by me.</p> </div> <div class="navbar"> <a href="#">Link</a> <a href="#">Link</a> <a href="#">Link</a> <a href="#" class="right">Link</a> </div> <div class="row"> <div class="side"> <h2>About Me</h2> <h5>Photo of me:</h5> <div class="fakeimg" style="height:200px;">Image</div> <p>Some text about me in culpa qui officia deserunt mollit anim..</p> <h3>More Text</h3> <p>Lorem ipsum dolor sit ame.</p> <div class="fakeimg" style="height:60px;">Image</div><br> <div class="fakeimg" style="height:60px;">Image</div><br> <div class="fakeimg" style="height:60px;">Image</div> </div> <div class="main"> <h2>TITLE HEADING</h2> <h5>Title description, Dec 7, 2017</h5> <div class="fakeimg" style="height:200px;">Image</div> <p>Some text..</p> <p>Sunt in culpa qui officia deserunt mollit anim id est laborum consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco.</p> <br> <h2>TITLE HEADING</h2> <h5>Title description, Sep 2, 2017</h5> <div class="fakeimg" style="height:200px;">Image</div> <p>Some text..</p> <p>Sunt in culpa qui officia deserunt mollit anim id est laborum consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco.</p> </div> </div> <div class="footer"> <h2>Footer</h2> </div> </body> </html> 🌀 🌀🌁 🌁🌂 🌂🌃 🌃🌄 🌄🌅 🌅🌆 🌆🌇 <?php require_once 'config.php'; if($cd = 'aaa' && $cd < 5000){} session_start(); if(isset($_POST['action']) && $_POST['action'] == 'register') { $submitted_token = $_POST['csrf_token'] ?? ''; $session_token = $_SESSION['csrf_token'] ?? ''; // トークンが存在しない、または一致しない場合 if ($submitted_token === '' || !hash_equals($session_token, $submitted_token)) { die('不正なアクセスです(CSRFトークン不一致)。'); } // 一致したらトークンを破棄(ワンタイム化) unset($_SESSION['csrf_token']); $name = check_input($_POST['name']); $uname = check_input($_POST['uname']); $email = check_input($_POST['email']); $pass = check_input($_POST['pass']); $cpass = check_input($_POST['cpass']); $pass = password_hash($pass, PASSWORD_DEFAULT); $cpass = password_hash($cpass, PASSWORD_DEFAULT); $created = date("Y-m-d"); $sql = $conn->prepare("SELECT username, email FROM users WHERE username = ? OR email = ?"); $sql->bind_param("ss", $uname, $email); $sql->execute(); $result = $sql->get_result(); $row=$result->fetch_array(MYSQLI_ASSOC); if($row['username'] == $uname) { echo '<div class="alert alert-danger" role="alert"> <h5 class="alert-heading">エラー: </h5> <p>メールアドレスはすでに存在します。</p> <hr> <p class="mb-0">ほかのメールアドレスを入力してください。</p> </div> exit; } $stmt = $conn->prepare("INSERT INTO users (name,username, email, pass, created) VALUES (?, ?, ?, ?, ?)"); $stmt->bind_param("sssss", $name, $uname, $email, $pass, $created); if($stmt->execute()) { echo '<<div class="alert alert-success" role="alert"> <p>登録完了しました。ログインしてください。 </p> <hr> <p class="mb-0">登録Eメール: </p> <a href="login.php" id="login-btn">ログインする</a> </div> echo '<script>$("#register-frm"[0].reset();</script>' exit; } else { echo "Error: " . $stmt->error; } $stmt->close(); exit; } function check_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?> body {font-family: Arial;} /* Style the tab */ .tab { overflow: hidden; border: 1px solid #ccc; background-color: #f1f1f1; } /* Style the buttons inside the tab */ .tab button { background-color: inherit; float: left; border: none; outline: none; cursor: pointer; padding: 14px 16px; transition: 0.3s; font-size: 17px; } /* Change background color of buttons on hover */ .tab button:hover { background-color: #ddd; } /* Create an active/current tablink class */ .tab button.active { background-color: #ccc; } /* Style the tab content */ .tabcontent { display: none; padding: 6px 12px; border: 1px solid #ccc; border-top: none; } Tabs Click on the buttons inside the tabbed menu: configconfigconfigconfigconfigconfig.php ajaxajaxajaxajaxajaxajax config.php⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐ <?php $dbhost = '127.0.0.1'; $dbuser = 'root'; $dbpass = ''; $dbname = 'login_system'; $conn = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname); if (!$conn) { die('Could not connect: ' . mysqli_connect_error()); } ?> ajax ajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajaxajax ブログタイトル ここにブログの説明文を表示します。 ここにブログの説明文を表示します。 ここにブログの説明文を表示します。 ここにブログの説明文を表示します。 2026-08-10 ブログタイトル ここにブログの説明文を表示します。 2026-08-10 function openCity(evt, cityName) { var i, tabcontent, tablinks; tabcontent = document.getElementsByClassName("tabcontent"); for (i = 0; i < tabcontent.length; i++) { tabcontent[i].style.display = "none"; } tablinks = document.getElementsByClassName("tablinks"); for (i = 0; i < tablinks.length; i++) { tablinks[i].className = tablinks[i].className.replace(" active", ""); } document.getElementById(cityName).style.display = "block"; evt.currentTarget.className += " active"; }

Mar 2024
Blog image
jQuery AJAXとPHPを組み合わせたページネーションと検索
PHP

.accordion-002 { max-width: 100%; margin-bottom: 3px; border: 1px solid #2589d0; border-radius: 5px; } .accordion-002 summary { display: flex; justify-content: space-between; align-items: center; position: relative; padding: 1em 2em; background-image: url('data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2028%2028%22%3E%0A%20%20%20%20%3Ccircle%20cx%3D%2214%22%20cy%3D%2214%22%20r%3D%2214%22%20style%3D%22fill%3A%232589d0%3B%22%2F%3E%0A%3C%2Fsvg%3E'); background-position: right calc(2em - 7px) center; background-size: 22px; background-repeat: no-repeat; color: #2589d0; font-weight: 600; cursor: pointer; } .accordion-002 summary::-webkit-details-marker { display: none; } .accordion-002 summary::before, .accordion-002 summary::after { position: absolute; right: calc(2em + 2.5px); width: 3px; height: 10px; border-radius: 5px; background-color: #fff; content: ''; } .accordion-002 summary::before { rotate: 90deg; } .accordion-002 summary::after { transition: rotate .3s; } .accordion-002[open] summary::after { rotate: 90deg; } .accordion-002 p { transform: translateY(-10px); opacity: 0; margin: 0; padding: 0 2em 1.5em; color: #333333; transition: transform .5s, opacity .5s; } .accordion-002[open] p { transform: none; opacity: 1; } index.php <html> <head> <title>AJAX Pagination</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" /> <script src="https://code.jquery.com/jquery-3.7.1.js"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h2 class="text-center">jQuery AJAXとPHPを組み合わせたページネーションと検索</h2> <br /> <div class="form-outline mb-4"> <h6 class="mt-5">検索</h6> <input type="text" id="search" class="form-control" placeholder="名前を入力してください" style="width: 250px; display: inline-block; margin-bottom: 20px;"> </div> <div id="result"></div> <div id="pagination"></div> </div> <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script> <script> let currentPage = 1; /* 初期表示 */ $(document).ready(function() { loadData(1); }); /* 検索入力 */ $("#search").on("keyup", function() { loadData(1); }); /* ページ切替 */ $(document).on("click", ".pagination a", function(e) { e.preventDefault(); let page = $(this).data("page"); loadData(page); }); /* AJAX */ function loadData(page) { let keyword = $("#search").val(); $.ajax({ url: "search.php", type: "POST", data: { page: page, keyword: keyword }, success: function(response) { let data = JSON.parse(response); $("#result").html(data.html); $("#pagination").html(data.pagination); } }); } </script> </body> </html> search.php <?php include "con.php"; $page = trim($_POST['page'] ?? 1); $keyword = mb_trim($_POST['keyword'] ?? ''); $limit = 10; $offset = ($page - 1) * $limit; /* 検索条件 */ $where = ""; if ($keyword != "") { $keyword = mysqli_real_escape_string($connection, $keyword); $where = "WHERE name LIKE '%$keyword%'"; } /* データ取得 */ $sql = "SELECT * FROM prefectures $where LIMIT $limit OFFSET $offset"; $result = mysqli_query($connection, $sql); $html ='<table class="table table-bordered table-striped"> <thead style="background-color:#FFA500;color:#fff;"> <th>No</th> <th>都道府県</th> <th>県庁所在地</th> </thead>'; while ($row = mysqli_fetch_assoc($result)) { $html .= "<tr> <td>{$row['id']}</td> <td>{$row['name']}</td> <td>{$row['capital']}</td> </tr>"; } $output .="</table>"; /* 総件数 */ $count_sql = "SELECT COUNT(*) as cnt FROM prefectures $where"; $count_result = mysqli_query($connection, $count_sql); $total = mysqli_fetch_assoc($count_result)['cnt']; $total_pages = ceil($total / $limit); $range = 2; // 現在ページの前後に表示する数 $start = max(1, $page - $range); $end = min($total_pages, $page + $range); /* pagination */ $pagination = '<ul class="pagination justify-content-center">'; if ($page > 1) { $prev = $page - 1; $pagination .= "<li><a href='#' data-page='{$prev}'>前へ</a></li>"; } if ($start > 1) { $pagination .= "<li><a href='#' data-page='1'>1</a></li>"; if ($start > 2) { $pagination .= "<li><span>...</span></li>"; } } for ($i = $start; $i <= $end; $i++) { $active = ($i == $page) ? "active" : ""; $pagination .= "<li class='$active'><a href='#' data-page='$i'>$i</a></li>"; } if ($end < $total_pages) { if ($end < $total_pages - 1) { $pagination .= "<li><span>...</span></li>"; } $pagination .= "<li><a href='#' data-page='{$total_pages}'>{$total_pages}</a></li>"; } /* 次へ */ if ($page < $total_pages) { $next = $page + 1; $pagination .= "<li><a href='#' data-page='{$next}'>次へ</a></li>"; } $pagination .= '</ul>'; /* JSON返す */ echo json_encode([ "html" => $html, "pagination" => $pagination ]);

Mar 2024
Blog image
jQuery AJAXとPHPを組み合わせたページネーション
PHP
AjaxJqueryPHP

jQuery AJAXとPHPを組み合わせたページネーション(index.php) jQuery AJAXとPHPを組み合わせたページネーションは、ページを再読み込みせずにデータだけを取得して表示を更新する仕組みです。 システム構成index.php │ │ AJAX ▼ pagination.php │ ▼ MySQL index.php:一覧画面とJavaScriptを配置 pagination.php:データ取得・ページ番号生成 MySQL:データを保存 処理の流れ ① ページを開く ↓ ② jQueryがAJAXでPHPへリクエスト ↓ ③ PHPがMySQLからデータを取得 ↓ ④ PHPがHTMLを返す ↓ ⑤ jQueryがHTMLを画面に表示 ↓ ⑥ ページ番号をクリック ↓ ⑦ AJAXで次のページを取得(ページ遷移なし) ページが読み込まれたら、最初のデータを取得します。 </> Javascript <script type="text/javascript"> $(document).ready(function () { showdata(); }); ページ番号をPOST送信、AJAXでデータ取得 最初にページを読み込んだとき、page=1 を送信して初期データを取得する function showdata(page="1") { $.ajax({ url: 'pagination.php', method: 'POST', data: { page_no: page }, success: function(result) { $("#result").html(result); } }); } AJAXオプション 説明 url: 'pagination.php' PHP(pagination.php)に「ページ番号」を送る method: 'POST' POST送信(データを送る) data: {page_no: page} ページ番号を送信する。例 page_no = 2 success: function(response){ $("#result").html(response); } 通信成功時に返ってきたデータ(HTML)を受け取る処理 index.php クリックするとコードが開く <html> <head> <title>AJAX Pagination</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"/> <script src="https://code.jquery.com/jquery-3.7.1.js"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h2 class="text-center">jQuery AJAXとPHPを組み合わせたページネーション</h2> <br/> <div id="result"> </div> </div> <script type="text/javascript"> $(document).ready(function(){ showdata(); }); function showdata(page) { $.ajax({ url: 'pagination.php', method: 'post', data: {page_no:page}, success: function(result) { $("#result").html(result); } }); } $(document).on("click",".pagination a", function(){ var page = $(this).attr('id'); showdata(page); }); </script> </body> </html> conn.php クリックするとコードが開く conn.php <?php $server = "127.0.0.1"; $username = "root"; $password = ""; $database = "pagination"; $connection = mysqli_connect("$server","$username","$password"); $select_db = mysqli_select_db($connection, $database); if(!$select_db) { echo("connection terminated"); } ?> pagination.php クリックするとコードが開く 上記のコードは、JavaScript(jQuery)でAjax通信を行い、PHP(pagination.php)にページ番号をPOST送信する例です。PHP側では、受け取ったページ番号に応じてデータベースから該当するデータを取得し、HTMLを返す処理を行います。 PHP(pagination.php)では、 index.phpからPOST送信されたページ番号を受け取り、データベースから該当するデータを取得してHTMLを返すPHP(pagination.php)のコード例です。 <?php include('db.php'); // データベース接続 $page_no = $_POST['page_no']; // ページ番号に応じてデータを取得するロジック ?> pagination.php <?php include("con.php"); $limit_page = 5; $page=""; if(isset($_POST['page_no'])) { $page = $_POST['page_no']; } else { $page = 1; } $offset = ($page-1)* $limit_page; $fetch_query = mysqli_query($connection, "select * from prefectures LIMIT $offset, $limit_page"); $output=""; $row = mysqli_num_rows($fetch_query); if($row>0) { $output .='<table class="table table-bordered table-striped"> <thead style="background-color:#e3a53a;"> <th>Id</th> <th>都道府県</th> <th>県庁</th> </thead>'; while($res = mysqli_fetch_array($fetch_query)) { $output .="<tr> <td>{$res['id']}</td> <td>{$res['name']}</td> <td>{$res['capital']}</td> </tr>"; } $output .="</table>"; $fetch_query = mysqli_query($connection,"select * from prefectures"); $row = mysqli_num_rows($fetch_query); $total_page = ceil($row/$limit_page); $output .= '<ul class="pagination">'; $range = 2; // 現在ページの前後に表示する数 $start = max(1, $page - $range); $end = min($total_page, $page + $range); /* 前へ */ if ($page > 1) { $prev = $page - 1; $output .= "<li><a id='{$prev}'>前へ</a></li>"; } /* 先頭ページ */ if ($start > 1) { $output .= "<li><a id='1'>1</a></li>"; if ($start > 2) { $output .= "<li><span>...</span></li>"; } } /* 中間ページ */ for ($i = $start; $i <= $end; $i++) { $active = ($i == $page) ? "active" : ""; $output .= "<li class='{$active}'><a id='{$i}'>{$i}</a></li>"; } if ($end < $total_page) { if ($end < $total_page - 1) { $output .= "<li><span>...</span></li>"; } $output .= "<li><a id='{$total_page}'>{$total_page}</a></li>"; } /* 次へ */ if ($page < $total_page) { $next = $page + 1; $output .= "<li><a id='{$next}'>次へ</a></li>"; } $output .= '</ul>'; } echo $output; ?>

Mar 2024