PHPでmySQLを操作してLIMITしてページを分けるとエラーはいて出力されません。
PHP
1<?php 2require('connect.php'); 3$page = $_REQUEST['page']; 4if ($page == '') { 5 $page = 1; 6} 7$start = ($page -1) * 5; 8 9$recordSet = mysqli_query($db,"SELECT m.name, i.* FROM makers m, my_items i WHERE m.id=i.maker_id ORDER BY id DESC LIMIT " . $start . ",5"); 10 ?> 11<!DOCTYPE html> 12<html lang="ja"> 13 <head> 14 <meta charset="UTF-8"> 15 <title>----タイトル----</title> 16 <meta name="description" content="----説明----"> 17 <meta name="viewport" content="width=device-width"> 18 <link rel="stylesheet" href="css/style.css"><!--場所指定--> 19 </head> 20 <body> 21 <p>登録する商品の情報を記入してください。</p> 22 <form id="frmInput" name="frmInput" method="post" action="indexok.php"> 23 <dl> 24 <dt> 25 <label for="maker_id">メーカーID</label> 26 </dt> 27 <dd> 28 <input name="maker_id" type="text" id="maker_id" size="10" maxlength="10" /> 29 </dd> 30 <dt> 31 <label for="item_name">商品名</label> 32 </dt> 33 <dd> 34 <input name="item_name" type="text" id="item_name" size="35" maxlength="255" /> 35 </dd> 36 <dt> 37 <label for="price">価格</label> 38 </dt> 39 <dd> 40 <input name="price" type="text" id="price" size="10" maxlength="10" /> 41 円</dd> 42 <dt> 43 <label for="keyword">キーワード</label> 44 </dt> 45 <dd> 46 <input name="keyword" type="text" id="keyword" size="50" maxlength="255" /> 47 </dd> 48 <input type="submit" value="登録する" /> 49 </form> 50 <table width="100%"> 51 <tr> 52 <th scope="col">ID</th> 53 <th scope="col">メーカー</th> 54 <th scope="col">商品名</th> 55 <th scope="col">価格</th> 56 <!--<th scope="col">編集・削除</th>--> 57 </tr> 58 <?php 59 while ($table = mysqli_fetch_assoc('$recordSet')) { 60 ?> 61 <tr> 62 <td><?php print(htmlspecialchars($table['id'])); ?></td> 63 <td><?php print(htmlspecialchars($table['name'])); ?></td> 64 <td><?php print(htmlspecialchars($table['item_name'])); ?></td> 65 <td><?php print(htmlspecialchars($table['price'])); ?></td> 66 67 </tr> 68 <?php 69 } 70 ?> 71 </table> 72 <ul class="paging"> 73 <li><a href="index.php?page=2">つぎ</a></li> 74 </ul> 75 </body> 76</html> 77
#ブラウザの表示
Notice: Undefined index: page in C:\xampp\htdocs\index.php on line 3
登録する商品の情報を記入してください。
メーカーID
商品名
価格
円
キーワード
Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, string given in C:\xampp\htdocs\index.php on line 59
ID メーカー 商品名 価格
・つぎ
回答3件
あなたの回答
tips
プレビュー