Maya1991

▪️sample06-1.php

Jul 28th, 2016
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 12.49 KB | None | 0 0
  1. ▪️sample06-1.php
  2.  
  3. <?php ini_set( 'display_errors', 1);?>
  4.  
  5.  
  6.  
  7.     <!--
  8. isset→引数に指定した変数が定義されているかどうか調べる変数
  9. &&は倫理演算子
  10. $a && $b $a又は$bが共にtrueの場合にtrue
  11. &&倫理積 2つの値が成り立つ時
  12. $_REQUEST→$_GET $_POST $_COOKIE $_FILESの値を取得します
  13.  
  14.  
  15. -->
  16.  
  17. <?php
  18. $japanese = "";
  19. $english = "";
  20. $example = "";
  21. // $id = "";
  22.  
  23. if (isset ( $_REQUEST ["japanese"] ) && isset ( $_REQUEST ["english"] ) && isset ( $_REQUEST ["example"] )) {
  24.     $japanese = $_REQUEST ["japanese"];
  25.     $english = $_REQUEST ["english"];
  26.     $example = $_REQUEST ["example"];
  27. //  $id = $_REQUEST ["id"];
  28. }
  29. ?>
  30.  
  31. <html>
  32. <head>
  33. <title>英単語メモ帳</title>
  34. <meta http-equiv="Content-Type" content="text/css" ; charset="UTF-8">
  35. <style type="text/css">
  36. div {
  37.     /*  padding: 100px; */
  38.     margin-left: 5px;
  39.     /*  margin-top: 1000px; */
  40.     background: url(yslr03.png);
  41.     background-repeat: no-repeat;
  42.     background-position: 100% 0%;
  43.     color: #000000;
  44.     scrollbar-base-color:white;
  45. }
  46.  
  47. iframe {
  48.     width: 1000px;
  49.     height: 500px;
  50.     /*  background: #ffffff url(top_mv_01_160203.png); */
  51.     background-attachment: fixed;
  52.     background: url(YSL-L5203900-main.png);
  53.     background-repeat: no-repeat;
  54.     background-position: 100% 100%;
  55. }
  56.  
  57. /* body{
  58.         scrollbar-arrow-color:deeppink;  */
  59. /*    scrollbar-face-color:mistyrose; */
  60. /*    scrollbar-highlight-color:white;  */
  61. /*    scrollbar-3dlight-color:white; */
  62. /*    scrollbar-track-color:white; */
  63. /*    scrollbar-shadow-color:hotpink; */
  64. /*    scrollbar-darkshadow-color:white;} */
  65.  
  66. </style>
  67.  
  68. </head>
  69. <body>
  70.     <img alt="http://www.emoticonswallpapers.com"
  71.         src="http://www.emoticonswallpapers.com/tipos/6/w.gif" />
  72.     <img alt="http://www.emoticonswallpapers.com"
  73.         src="http://www.emoticonswallpapers.com/tipos/6/o.gif" />
  74.     <img alt="http://www.emoticonswallpapers.com"
  75.         src="http://www.emoticonswallpapers.com/tipos/6/r.gif" />
  76.     <img alt="http://www.emoticonswallpapers.com"
  77.         src="http://www.emoticonswallpapers.com/tipos/6/d.gif" />
  78.     <img alt="http://www.emoticonswallpapers.com"
  79.         src="http://www.emoticonswallpapers.com/tipos/6/s.gif" />   
  80.     <img alt="http://www.emoticonswallpapers.com"
  81.         src="http://www.emoticonswallpapers.com/tipos/6/m.gif" />
  82.     <img alt="http://www.emoticonswallpapers.com"
  83.         src="http://www.emoticonswallpapers.com/tipos/6/e.gif" />
  84.     <img alt="http://www.emoticonswallpapers.com"
  85.         src="http://www.emoticonswallpapers.com/tipos/6/m.gif" />
  86.     <img alt="http://www.emoticonswallpapers.com"
  87.         src="http://www.emoticonswallpapers.com/tipos/6/o.gif" />
  88.     <br>
  89.     <a style="font-size: 11px;" href="http://www.emoticonswallpapers.com"></a>
  90.     <div>
  91.         <p>
  92.             <i frame src="sample06-2.php">英単語帳</iframe>
  93.        
  94.         </p>
  95.         <p>
  96.             <iframe src="sample06-2.php" allowtransparency="true">代替内容</iframe>
  97.         </p>
  98.  
  99.     </div>
  100. <body>
  101. <?php /* ?>
  102.     <form method="POST" action="input_do3.php">
  103.         <p>単語登録</p>
  104.         日本語 <input type="text" name="japanese" size="20" maxlength="255"
  105.             value="<?php echo $japanese;?>"> <br> 英語<input type="text"
  106.             name="english" size="20" maxlength="100"
  107.             value="<?php echo $english;?>"> <br> 例文<input type="text"
  108.             name="example" size="20" maxlength="100"
  109.             value="<?php echo $example;?>"> <input type="submit" value="登録">
  110.  
  111.     </form>
  112.  
  113.  
  114.     <!--表で表示-->
  115.  
  116.     <!--
  117. mysqli_connect_error直近の接続エラーの内容を文字列で返す
  118. or→又は
  119. mysqli_query→データベース上でクエリを実行する
  120. mysqli_set_charsetクライアントのデフォルト文字セットを設定する
  121. mysqli_fetch_assoc→結果の行を連想配列で取得する
  122. while文→ある条件が成り立っている間だけ処理を繰り返し実行する制御文
  123. 主に繰り返す回数がわからないときに使う
  124. <!--表を表示2(正)-->
  125. <?php
  126.  
  127. require ('dbconnect.php');
  128. $page = $_REQUEST ['page'];
  129. if ($page == '') {
  130.     $page = 1;
  131. }
  132. $page = max ( $page, 1 );
  133. $start = ($page - 1) * 5;
  134. $recordSet = mysqli_query ( $db, 'SELECT * FROM Cafe_data ORDER BY CafeEnglish DESC LIMIT ' . $start . ',5' );
  135. ?>
  136.  
  137. <table width="100%">
  138.         <tr align=center bgcolor=#ffe4b5>
  139.             <th scope="col">日本語</th>
  140.             <th scope="col">英語</th>
  141.             <th scope="col">例文</th>
  142.             <th scope="col">ID</th>
  143.             <th scope="col">編集</th>
  144.             <th scope="col">削除</th>
  145.         </tr>
  146.    
  147. <?php
  148. while ( $table = mysqli_fetch_assoc ( $recordSet ) ) {
  149.     ?>
  150.  
  151.     <tr>
  152.             <td rowspan=1 align=center bgcolor=#ffe4e1>
  153. <?php print(htmlspecialchars($table['CafeJapanese'])); ?></td>
  154.             <td><?php print(htmlspecialchars($table['CafeEnglish'])); ?></td>
  155.             <td><?php print(htmlspecialchars($table['CafeSignificance'])); ?></td>
  156.             <td><?php print(htmlspecialchars($table['ID'])); ?></td>
  157.  
  158.             <td><a
  159.                 href="uupdate_01.php?ID=<?php print(htmlspecialchars($table['ID']));?>">編集</a></td>
  160.             <td><a
  161.                 href="delete_01.php?ID=<?php print(htmlspecialchars($table['ID']));?>">削除</a></td>
  162.             </form>
  163.  
  164.         </tr>
  165.    
  166. <?php
  167. }
  168. ?>
  169. </table>
  170. <!--ulは順序のないリストを記述する-->
  171.     <ul class="paging">
  172.         <li><a href="sample06-1.php?page=<?php
  173.        
  174.         print ($page - 1) ;
  175.         ?>">前のページへ</a></li>
  176.         <li><a href="sample06-1.php?page=<?php
  177.        
  178.         print ($page + 1) ;
  179.         ?>">次のページへ</a></li>
  180.     </ul>
  181. <?php   */ ?>
  182.  
  183. </body>
  184. </html>
  185.  
  186.  
  187. ▪️sample06-2.php
  188.  
  189. <!DOCTYPE html>
  190. <html>
  191. <head>
  192. <meta charset="UTF-8">
  193. <title>Insert title here</title>
  194. <style type="text/css">
  195.  
  196. body {
  197.     scrollbar-track-color: #ffffff;
  198.     scrollbar-face-color: #ffffff;
  199.     scrollbar-arrow-color: #00efdb;
  200.     scrollbar-shadow-color: #00efdb;
  201.     scrollbar-highlight-color: #00efdb;
  202.     scrollbar-darkshadow-color: #ffffff;
  203.     scrollbar-3dlight-color: #ffffff;
  204. }
  205.  
  206. h1 {
  207.     font-size: 100%;
  208. }
  209.  
  210. p {
  211.     margin-top: 30px;
  212. }
  213. </style>
  214.  
  215. </head>
  216. <body>
  217. <?php
  218. $japanese = "";
  219. $english = "";
  220. $example = "";
  221.  
  222. if (isset ( $_REQUEST ["japanese"] ) && isset ( $_REQUEST ["english"] ) && isset ( $_REQUEST ["example"] )) {
  223.     $japanese = $_REQUEST ["japanese"];
  224.     $english = $_REQUEST ["english"];
  225.     $example = $_REQUEST ["example"];
  226. }
  227. ?>
  228.  
  229.  
  230.  
  231.  
  232.  
  233. <html>
  234. <body>
  235.     <form method="POST" action="input_do3.php">
  236.         <p>単語登録</p>
  237.         日本語 <input type="text" name="japanese" size="30" maxlength="200"
  238.             value="<?php echo $japanese;?>"> <br> 英語<input type="text"
  239.             name="english" size="30" maxlength="100"
  240.             value="<?php echo $english;?>"> <br> 例文<input type="text"
  241.             name="example" size="30" maxlength="100"
  242.             value="<?php echo $example;?>"> <input type="submit" value="登録">
  243.  
  244.     </form>
  245.  
  246.  
  247.     <!--表で表示-->
  248.  
  249.     <!--
  250. mysqli_connect_error直近の接続エラーの内容を文字列で返す
  251. or→又は
  252. mysqli_query→データベース上でクエリを実行する
  253. mysqli_set_charsetクライアントのデフォルト文字セットを設定する
  254. mysqli_fetch_assoc→結果の行を連想配列で取得する
  255. while文→ある条件が成り立っている間だけ処理を繰り返し実行する制御文
  256. 主に繰り返す回数がわからないときに使う
  257. <!--表を表示2(正)-->
  258. <?php
  259.  
  260. require ('dbconnect.php');
  261. $page = $_REQUEST ['page'];
  262. if ($page == '') {
  263.     $page = 1;
  264. }
  265. $page = max ( $page, 1 );
  266. $start = ($page - 1) * 5;
  267. /*
  268.  * DESK(Descending order)→大きい順に並べる。ASC(Ascending order)→小さい順に並べる
  269.  * LIMIT→件数を制限する
  270.  */
  271.  
  272. $recordSet = mysqli_query ( $db, 'SELECT * FROM Cafe_data ORDER BY ID DESC LIMIT ' . $start . ',5' );
  273. // $recordSet = mysqli_query( $db, 'SELECT * FROM Cafe_data ORDER BY ID DESK LIMIT ' . $start . ',5');
  274. // $recordSet = mysqli_query ( $db, 'SELECT * FROM Cafe_data ORDER BY CafeEnglish DESC LIMIT ' . $start . ',5' );
  275. ?>
  276.  
  277. <table width="100%">
  278.         <tr align=center bgcolor=#ffe4b5>
  279.             <th scope="col">日本語</th>
  280.             <th scope="col">英語</th>
  281.             <th scope="col">例文</th>
  282.             <th scope="col">ID</th>
  283.             <th scope="col">編集</th>
  284.             <th scope="col">削除</th>
  285.         </tr>
  286.    
  287. <?php
  288. while ( $table = mysqli_fetch_assoc ( $recordSet ) ) {
  289.     ?>
  290.  
  291.     <tr>
  292.             <td rowspan=1 align=center bgcolor=#ffe4e1>
  293. <?php print(htmlspecialchars($table['CafeJapanese'])); ?></td>
  294.             <td><?php print(htmlspecialchars($table['CafeEnglish'])); ?></td>
  295.             <td><?php print(htmlspecialchars($table['CafeSignificance'])); ?></td>
  296.             <td><?php print(htmlspecialchars($table['ID'])); ?></td>
  297.  
  298.             <td><a
  299.                 href="uupdate_01.php?ID=<?php print(htmlspecialchars($table['ID'], ENT_QUOTES));?>">編集</a></td>
  300.             <td><a
  301.                 href="delete_01.php?ID=<?php print(htmlspecialchars($table['ID'], ENT_QUOTES));?>">削除</a></td>
  302.             </form>
  303.  
  304.         </tr>
  305.    
  306. <?php
  307. }
  308. ?>
  309. </table>
  310.  
  311.     <ul class="paging">
  312.         <li><a href="sample06-2.php?page=<?php
  313.        
  314.         print ($page - 1) ;
  315.         ?>">前のページへ</a></li>
  316.         <li><a href="sample06-2.php?page=<?php
  317.        
  318.         print ($page + 1) ;
  319.         ?>">次のページへ</a></li>
  320.     </ul>
  321.     <h1>英単語集</h1>
  322.  
  323.     <table border=1 width=900>
  324.         <tr align=center bgcolor=#ffe4b5>
  325.             <td align=center>日本語</td>
  326.             <td align=center>英語</td>
  327.             <td align=center>例文</td>
  328.         </tr>
  329.         <tr>
  330.             <td rowspan=1 align=center bgcolor=#ffe4e1>なす</td>
  331.             <td>eggplant</td>
  332.             <td>Pickled cucumbers and egg plants.きゅうりとなすの揚げ物</td>
  333.         </tr>
  334.         <tr>
  335.             <td rowspan=1 align=center bgcolor=#ffe4e1>鰻</td>
  336.             <td>eel</td>
  337.             <td>a bowl of eel and rice鰻丼</td>
  338.         </tr>
  339.         <tr>
  340.             <td rowspan=1 align=center bgcolor=#ffe4e1>ぶり</td>
  341.             <td>yellowtail</td>
  342.             <td>I'm eating yellowtail.</td>
  343.         </tr>
  344.         <tr>
  345.             <td rowspan1 align=center bgcolor=#ffe4e1>カラス</td>
  346.             <td>crow</td>
  347.             <td>Stone the crows!</td>
  348.         </tr>
  349.         <tr>
  350.             <td rowspan1 align=center bgcolor=#ffe4e1>西洋かぼちゃ</td>
  351.             <td>squash</td>
  352.             <td>I ate a squash.</td>
  353.         </tr>
  354.         <tr>
  355.             <td rowspan1 align=center bgcolor=#ffe4e1>すずめ</td>
  356.             <td>sparrow</td>
  357.             <td>She is sparrow"s fart.</td>
  358.         </tr>
  359.         <tr>
  360.             <td rowspan1 align=center bgcolor=#ffe4e1>くらげ</td>
  361.             <td>jellyfish</td>
  362.             <td>I ate jellyfish last night.</td>
  363.         </tr>
  364.         <tr>
  365.             <td rowspan1 align=center bgcolor=#ffe4e1>ヒトデ</td>
  366.             <td>star fish</td>
  367.             <td>There are some starfishe in the sea.</td>
  368.         </tr>
  369.     </table>
  370.  
  371. </body>
  372. </html>
  373.  
  374. ▪️input_do3.php
  375. <?php ini_set('display_errors', 1 );?>
  376. <html>
  377. <head>
  378.     <title>testtest</title>
  379. </head>
  380. <body>
  381.  
  382. <?php
  383. require('dbconnect.php');
  384.  
  385. //echo 'aaaa';
  386.  
  387. $sql = sprintf('INSERT INTO Cafe_data SET CafeJapanese="%s",
  388. CafeEnglish="%s", CafeSignificance="%s" ',
  389.    
  390.      mysqli_real_escape_string($db, $_POST['japanese']),
  391.      mysqli_real_escape_string($db, $_POST['english']),
  392.      mysqli_real_escape_string($db, $_POST['example'])
  393. );
  394. //echo $sql;
  395. mysqli_query($db, $sql) or die(mysqli_error($db));
  396.  
  397. ?>
  398.  
  399. <p>単語を登録しました</p>
  400. <p><a href="sample06-2.php">一覧に戻る</a></p>
  401.  
  402. ▪️uupdate_01.php
  403.  
  404. <!-- ENT_QUOTES→ダブルクォート、シングルクォートの両方を変換します。 -->
  405. <?php ini_set('display_errors', 1 );?>
  406.  
  407. <?php
  408. require('dbconnect.php');
  409.  
  410. $id = $_REQUEST['ID'];
  411. $sql = sprintf("SELECT * FROM Cafe_data WHERE ID=%d",
  412.  mysqli_real_escape_string($db, $id)
  413.  );
  414.  $recordSet = mysqli_query($db, $sql);
  415.  $data = mysqli_fetch_assoc($recordSet);
  416.  ?>
  417.  
  418. <html>
  419. <body>
  420. <form id="frmUpdate" name="frmUpdate" method="post" action="input_do3_delete.php">
  421. <p>英単語集</p>
  422. <label for="japanese">日本語</label>
  423. <input name="japanese" type="text" id="japanese" size="20" maxlength="100"
  424. value="<?php print(htmlspecialchars($data['CafeJapanese'], ENT_QUOTES)); ?>" />
  425. <br>
  426. <label for ="english">英語</label>
  427. <input type="text" id="english" name="english" size="20" maxlength="100" value="<?php print(htmlspecialchars($data
  428. ['CafeEnglish'], ENT_QUOTES)); ?>" />
  429. <br>
  430. <label for = "example">例文</label><input type="text" id="example" name="example" size="20" maxlength="100" value="<?php print(htmlspecialchars($data
  431. ['CafeSignificance'], ENT_QUOTES)); ?>" />
  432.  
  433.  
  434. <input type="submit" value="変更する" />
  435. <input type="hidden" name="id" value="<?php print(htmlspecialchars($data['ID'], ENT_QUOTES)) ?>" />
  436. </form>
  437. </html>
  438.  
  439.  
  440. ▪️delete_01.php
  441.  
  442. <?php
  443. require ('dbconnect.php');
  444. $id = $_REQUEST['ID'];
  445. $sql = sprintf ( "DELETE FROM Cafe_data WHERE ID=%d",
  446.         mysqli_real_escape_string ( $db,$id )
  447. );
  448. mysqli_query ( $db, $sql ) or die ( mysqli_error ( $db ) );
  449. // mysqli_fetch_assoc — 結果の行を連想配列で取得する
  450. $recordSet = mysqli_fetch_assoc($recordSet);
  451. ?>
  452. <p>削除しました</p>
  453. <p><a href="sample06-2.php">一覧へ戻る</a></p>
Advertisement
Add Comment
Please, Sign In to add comment