Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ▪️sample06-1.php
- <?php ini_set( 'display_errors', 1);?>
- <!--
- isset→引数に指定した変数が定義されているかどうか調べる変数
- &&は倫理演算子
- $a && $b $a又は$bが共にtrueの場合にtrue
- &&倫理積 2つの値が成り立つ時
- $_REQUEST→$_GET $_POST $_COOKIE $_FILESの値を取得します
- -->
- <?php
- $japanese = "";
- $english = "";
- $example = "";
- // $id = "";
- if (isset ( $_REQUEST ["japanese"] ) && isset ( $_REQUEST ["english"] ) && isset ( $_REQUEST ["example"] )) {
- $japanese = $_REQUEST ["japanese"];
- $english = $_REQUEST ["english"];
- $example = $_REQUEST ["example"];
- // $id = $_REQUEST ["id"];
- }
- ?>
- <html>
- <head>
- <title>英単語メモ帳</title>
- <meta http-equiv="Content-Type" content="text/css" ; charset="UTF-8">
- <style type="text/css">
- div {
- /* padding: 100px; */
- margin-left: 5px;
- /* margin-top: 1000px; */
- background: url(yslr03.png);
- background-repeat: no-repeat;
- background-position: 100% 0%;
- color: #000000;
- scrollbar-base-color:white;
- }
- iframe {
- width: 1000px;
- height: 500px;
- /* background: #ffffff url(top_mv_01_160203.png); */
- background-attachment: fixed;
- background: url(YSL-L5203900-main.png);
- background-repeat: no-repeat;
- background-position: 100% 100%;
- }
- /* body{
- scrollbar-arrow-color:deeppink; */
- /* scrollbar-face-color:mistyrose; */
- /* scrollbar-highlight-color:white; */
- /* scrollbar-3dlight-color:white; */
- /* scrollbar-track-color:white; */
- /* scrollbar-shadow-color:hotpink; */
- /* scrollbar-darkshadow-color:white;} */
- </style>
- </head>
- <body>
- <img alt="http://www.emoticonswallpapers.com"
- src="http://www.emoticonswallpapers.com/tipos/6/w.gif" />
- <img alt="http://www.emoticonswallpapers.com"
- src="http://www.emoticonswallpapers.com/tipos/6/o.gif" />
- <img alt="http://www.emoticonswallpapers.com"
- src="http://www.emoticonswallpapers.com/tipos/6/r.gif" />
- <img alt="http://www.emoticonswallpapers.com"
- src="http://www.emoticonswallpapers.com/tipos/6/d.gif" />
- <img alt="http://www.emoticonswallpapers.com"
- src="http://www.emoticonswallpapers.com/tipos/6/s.gif" />
- <img alt="http://www.emoticonswallpapers.com"
- src="http://www.emoticonswallpapers.com/tipos/6/m.gif" />
- <img alt="http://www.emoticonswallpapers.com"
- src="http://www.emoticonswallpapers.com/tipos/6/e.gif" />
- <img alt="http://www.emoticonswallpapers.com"
- src="http://www.emoticonswallpapers.com/tipos/6/m.gif" />
- <img alt="http://www.emoticonswallpapers.com"
- src="http://www.emoticonswallpapers.com/tipos/6/o.gif" />
- <br>
- <a style="font-size: 11px;" href="http://www.emoticonswallpapers.com"></a>
- <div>
- <p>
- <i frame src="sample06-2.php">英単語帳</iframe>
- </p>
- <p>
- <iframe src="sample06-2.php" allowtransparency="true">代替内容</iframe>
- </p>
- </div>
- <body>
- <?php /* ?>
- <form method="POST" action="input_do3.php">
- <p>単語登録</p>
- 日本語 <input type="text" name="japanese" size="20" maxlength="255"
- value="<?php echo $japanese;?>"> <br> 英語<input type="text"
- name="english" size="20" maxlength="100"
- value="<?php echo $english;?>"> <br> 例文<input type="text"
- name="example" size="20" maxlength="100"
- value="<?php echo $example;?>"> <input type="submit" value="登録">
- </form>
- <!--表で表示-->
- <!--
- mysqli_connect_error直近の接続エラーの内容を文字列で返す
- or→又は
- mysqli_query→データベース上でクエリを実行する
- mysqli_set_charsetクライアントのデフォルト文字セットを設定する
- mysqli_fetch_assoc→結果の行を連想配列で取得する
- while文→ある条件が成り立っている間だけ処理を繰り返し実行する制御文
- 主に繰り返す回数がわからないときに使う
- <!--表を表示2(正)-->
- <?php
- require ('dbconnect.php');
- $page = $_REQUEST ['page'];
- if ($page == '') {
- $page = 1;
- }
- $page = max ( $page, 1 );
- $start = ($page - 1) * 5;
- $recordSet = mysqli_query ( $db, 'SELECT * FROM Cafe_data ORDER BY CafeEnglish DESC LIMIT ' . $start . ',5' );
- ?>
- <table width="100%">
- <tr align=center bgcolor=#ffe4b5>
- <th scope="col">日本語</th>
- <th scope="col">英語</th>
- <th scope="col">例文</th>
- <th scope="col">ID</th>
- <th scope="col">編集</th>
- <th scope="col">削除</th>
- </tr>
- <?php
- while ( $table = mysqli_fetch_assoc ( $recordSet ) ) {
- ?>
- <tr>
- <td rowspan=1 align=center bgcolor=#ffe4e1>
- <?php print(htmlspecialchars($table['CafeJapanese'])); ?></td>
- <td><?php print(htmlspecialchars($table['CafeEnglish'])); ?></td>
- <td><?php print(htmlspecialchars($table['CafeSignificance'])); ?></td>
- <td><?php print(htmlspecialchars($table['ID'])); ?></td>
- <td><a
- href="uupdate_01.php?ID=<?php print(htmlspecialchars($table['ID']));?>">編集</a></td>
- <td><a
- href="delete_01.php?ID=<?php print(htmlspecialchars($table['ID']));?>">削除</a></td>
- </form>
- </tr>
- <?php
- }
- ?>
- </table>
- <!--ulは順序のないリストを記述する-->
- <ul class="paging">
- <li><a href="sample06-1.php?page=<?php
- print ($page - 1) ;
- ?>">前のページへ</a></li>
- <li><a href="sample06-1.php?page=<?php
- print ($page + 1) ;
- ?>">次のページへ</a></li>
- </ul>
- <?php */ ?>
- </body>
- </html>
- ▪️sample06-2.php
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>Insert title here</title>
- <style type="text/css">
- body {
- scrollbar-track-color: #ffffff;
- scrollbar-face-color: #ffffff;
- scrollbar-arrow-color: #00efdb;
- scrollbar-shadow-color: #00efdb;
- scrollbar-highlight-color: #00efdb;
- scrollbar-darkshadow-color: #ffffff;
- scrollbar-3dlight-color: #ffffff;
- }
- h1 {
- font-size: 100%;
- }
- p {
- margin-top: 30px;
- }
- </style>
- </head>
- <body>
- <?php
- $japanese = "";
- $english = "";
- $example = "";
- if (isset ( $_REQUEST ["japanese"] ) && isset ( $_REQUEST ["english"] ) && isset ( $_REQUEST ["example"] )) {
- $japanese = $_REQUEST ["japanese"];
- $english = $_REQUEST ["english"];
- $example = $_REQUEST ["example"];
- }
- ?>
- <html>
- <body>
- <form method="POST" action="input_do3.php">
- <p>単語登録</p>
- 日本語 <input type="text" name="japanese" size="30" maxlength="200"
- value="<?php echo $japanese;?>"> <br> 英語<input type="text"
- name="english" size="30" maxlength="100"
- value="<?php echo $english;?>"> <br> 例文<input type="text"
- name="example" size="30" maxlength="100"
- value="<?php echo $example;?>"> <input type="submit" value="登録">
- </form>
- <!--表で表示-->
- <!--
- mysqli_connect_error直近の接続エラーの内容を文字列で返す
- or→又は
- mysqli_query→データベース上でクエリを実行する
- mysqli_set_charsetクライアントのデフォルト文字セットを設定する
- mysqli_fetch_assoc→結果の行を連想配列で取得する
- while文→ある条件が成り立っている間だけ処理を繰り返し実行する制御文
- 主に繰り返す回数がわからないときに使う
- <!--表を表示2(正)-->
- <?php
- require ('dbconnect.php');
- $page = $_REQUEST ['page'];
- if ($page == '') {
- $page = 1;
- }
- $page = max ( $page, 1 );
- $start = ($page - 1) * 5;
- /*
- * DESK(Descending order)→大きい順に並べる。ASC(Ascending order)→小さい順に並べる
- * LIMIT→件数を制限する
- */
- $recordSet = mysqli_query ( $db, 'SELECT * FROM Cafe_data ORDER BY ID DESC LIMIT ' . $start . ',5' );
- // $recordSet = mysqli_query( $db, 'SELECT * FROM Cafe_data ORDER BY ID DESK LIMIT ' . $start . ',5');
- // $recordSet = mysqli_query ( $db, 'SELECT * FROM Cafe_data ORDER BY CafeEnglish DESC LIMIT ' . $start . ',5' );
- ?>
- <table width="100%">
- <tr align=center bgcolor=#ffe4b5>
- <th scope="col">日本語</th>
- <th scope="col">英語</th>
- <th scope="col">例文</th>
- <th scope="col">ID</th>
- <th scope="col">編集</th>
- <th scope="col">削除</th>
- </tr>
- <?php
- while ( $table = mysqli_fetch_assoc ( $recordSet ) ) {
- ?>
- <tr>
- <td rowspan=1 align=center bgcolor=#ffe4e1>
- <?php print(htmlspecialchars($table['CafeJapanese'])); ?></td>
- <td><?php print(htmlspecialchars($table['CafeEnglish'])); ?></td>
- <td><?php print(htmlspecialchars($table['CafeSignificance'])); ?></td>
- <td><?php print(htmlspecialchars($table['ID'])); ?></td>
- <td><a
- href="uupdate_01.php?ID=<?php print(htmlspecialchars($table['ID'], ENT_QUOTES));?>">編集</a></td>
- <td><a
- href="delete_01.php?ID=<?php print(htmlspecialchars($table['ID'], ENT_QUOTES));?>">削除</a></td>
- </form>
- </tr>
- <?php
- }
- ?>
- </table>
- <ul class="paging">
- <li><a href="sample06-2.php?page=<?php
- print ($page - 1) ;
- ?>">前のページへ</a></li>
- <li><a href="sample06-2.php?page=<?php
- print ($page + 1) ;
- ?>">次のページへ</a></li>
- </ul>
- <h1>英単語集</h1>
- <table border=1 width=900>
- <tr align=center bgcolor=#ffe4b5>
- <td align=center>日本語</td>
- <td align=center>英語</td>
- <td align=center>例文</td>
- </tr>
- <tr>
- <td rowspan=1 align=center bgcolor=#ffe4e1>なす</td>
- <td>eggplant</td>
- <td>Pickled cucumbers and egg plants.きゅうりとなすの揚げ物</td>
- </tr>
- <tr>
- <td rowspan=1 align=center bgcolor=#ffe4e1>鰻</td>
- <td>eel</td>
- <td>a bowl of eel and rice鰻丼</td>
- </tr>
- <tr>
- <td rowspan=1 align=center bgcolor=#ffe4e1>ぶり</td>
- <td>yellowtail</td>
- <td>I'm eating yellowtail.</td>
- </tr>
- <tr>
- <td rowspan1 align=center bgcolor=#ffe4e1>カラス</td>
- <td>crow</td>
- <td>Stone the crows!</td>
- </tr>
- <tr>
- <td rowspan1 align=center bgcolor=#ffe4e1>西洋かぼちゃ</td>
- <td>squash</td>
- <td>I ate a squash.</td>
- </tr>
- <tr>
- <td rowspan1 align=center bgcolor=#ffe4e1>すずめ</td>
- <td>sparrow</td>
- <td>She is sparrow"s fart.</td>
- </tr>
- <tr>
- <td rowspan1 align=center bgcolor=#ffe4e1>くらげ</td>
- <td>jellyfish</td>
- <td>I ate jellyfish last night.</td>
- </tr>
- <tr>
- <td rowspan1 align=center bgcolor=#ffe4e1>ヒトデ</td>
- <td>star fish</td>
- <td>There are some starfishe in the sea.</td>
- </tr>
- </table>
- </body>
- </html>
- ▪️input_do3.php
- <?php ini_set('display_errors', 1 );?>
- <html>
- <head>
- <title>testtest</title>
- </head>
- <body>
- <?php
- require('dbconnect.php');
- //echo 'aaaa';
- $sql = sprintf('INSERT INTO Cafe_data SET CafeJapanese="%s",
- CafeEnglish="%s", CafeSignificance="%s" ',
- mysqli_real_escape_string($db, $_POST['japanese']),
- mysqli_real_escape_string($db, $_POST['english']),
- mysqli_real_escape_string($db, $_POST['example'])
- );
- //echo $sql;
- mysqli_query($db, $sql) or die(mysqli_error($db));
- ?>
- <p>単語を登録しました</p>
- <p><a href="sample06-2.php">一覧に戻る</a></p>
- ▪️uupdate_01.php
- <!-- ENT_QUOTES→ダブルクォート、シングルクォートの両方を変換します。 -->
- <?php ini_set('display_errors', 1 );?>
- <?php
- require('dbconnect.php');
- $id = $_REQUEST['ID'];
- $sql = sprintf("SELECT * FROM Cafe_data WHERE ID=%d",
- mysqli_real_escape_string($db, $id)
- );
- $recordSet = mysqli_query($db, $sql);
- $data = mysqli_fetch_assoc($recordSet);
- ?>
- <html>
- <body>
- <form id="frmUpdate" name="frmUpdate" method="post" action="input_do3_delete.php">
- <p>英単語集</p>
- <label for="japanese">日本語</label>
- <input name="japanese" type="text" id="japanese" size="20" maxlength="100"
- value="<?php print(htmlspecialchars($data['CafeJapanese'], ENT_QUOTES)); ?>" />
- <br>
- <label for ="english">英語</label>
- <input type="text" id="english" name="english" size="20" maxlength="100" value="<?php print(htmlspecialchars($data
- ['CafeEnglish'], ENT_QUOTES)); ?>" />
- <br>
- <label for = "example">例文</label><input type="text" id="example" name="example" size="20" maxlength="100" value="<?php print(htmlspecialchars($data
- ['CafeSignificance'], ENT_QUOTES)); ?>" />
- <input type="submit" value="変更する" />
- <input type="hidden" name="id" value="<?php print(htmlspecialchars($data['ID'], ENT_QUOTES)) ?>" />
- </form>
- </html>
- ▪️delete_01.php
- <?php
- require ('dbconnect.php');
- $id = $_REQUEST['ID'];
- $sql = sprintf ( "DELETE FROM Cafe_data WHERE ID=%d",
- mysqli_real_escape_string ( $db,$id )
- );
- mysqli_query ( $db, $sql ) or die ( mysqli_error ( $db ) );
- // mysqli_fetch_assoc — 結果の行を連想配列で取得する
- $recordSet = mysqli_fetch_assoc($recordSet);
- ?>
- <p>削除しました</p>
- <p><a href="sample06-2.php">一覧へ戻る</a></p>
Advertisement
Add Comment
Please, Sign In to add comment