よくわかるPHPの教科書のエラー?について

このQ&Aのポイント
  • PHPの教科書に記載されているよくわかるPHPの教科書5.5対応のプログラムで、ファイルを開くと「Undefined index: page」というエラーが表示されます。
  • 次のページまたは前のページを押すとエラーは消えますが、エラーを非表示にせずにプログラム内で解決する方法を知りたいです。
  • 初心者なので、できるだけ分かりやすい解決方法を教えてください。
回答を見る
  • ベストアンサー

よくわかるPHPの教科書のエラー?について

わからないところがあるので教えて下さい。 (コード) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www. w3.org/TR/xhtmll/DTD/xhtmll- transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>PHP入門</title> </head> <body> <?php require('dbconnect.php'); $page = $_REQUEST['page']; if($page =='') { $page =1; } $page = max($page, 1); //最終ページを取得する $sql ='SELECT COUNT(*) AS cnt FROM my_items'; $recordSet = mysqli_query($db, $sql); $table = mysqli_fetch_assoc($recordSet); $maxPage = ceil($table['cnt'] /5); $page = min($page, $maxPage); $start = ($page - 1) * 5; $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'); ?> <p><a href="input.php">新しい商品を登録する。</a></p> <table width="100%"> <tr> <th scope="col">ID</th> <th scope="col">メーカー</th> <th scope="col">商品名</th> <th scope="col">価格</th> <th scope="col">編集・削除</th> </tr> <?php while($table = mysqli_fetch_assoc($recordSet)) { ?> <tr> <td><?php print(htmlspecialchars($table['id'])); ?></td> <td><?php print(htmlspecialchars($table['name'])); ?></td> <td><?php print(htmlspecialchars($table['item_name'])); ?></td> <td><?php print(htmlspecialchars($table['price'])); ?></td> <td><a href="update.php?id=<?php print(htmlspecialchars($table['id'])); ?>">編集</a> <a href="delete.php?id=<?php print(htmlspecialchars($table['id'])); ?>" onclick="return confirm('削除してもよろしいですか?');">削除</a> </td> </tr> <?php } ?> </table> <ul class="paging"> <?php if($page > 1) { ?> <li><a href="index.php?page=<?php print($page - 1); ?>">前のページへ </a></li> <?php } else { ?> <li>前のページへ</li> <?php } ?> <?php if($page < $maxPage) { ?> <li><a href="index.php?page=<?php print($page + 1); ?>">次のページへ </a></li> <?php } else { ?> <li>次のページへ</li> <?php } ?> </ul> </body> </html> 参考書?はよくわかるPHPの教科書5.5対応なのですが、一番初めにこのファイルを開くと Notice: Undefined index: page in C:\xampp\htdocs\shop\index.php on line 14っとエラー?が出ます。 次のページ、前のページを押すとエラー?は消えるのですが、とっても気になります。 なるべくなら、エラーを非表示にせずにプログラム内で問題を解決したいのですが・・・ 初心者なのでどうして良いかわかりません。 出来れば、とってもわかりやすい解決を出来ればお願いしたいです。(馬鹿なので・・・) よろしくお願いします。

  • PHP
  • 回答数3
  • ありがとう数1

質問者が選んだベストアンサー

  • ベストアンサー
  • ONEONE
  • ベストアンサー率48% (279/575)
回答No.3

最初のページのURLには 「?page=数字」というクエリストリングがないために、 $_REQUEST['page']と書くと Notice: Undefined indexというエラーが出ます。 $page = $_REQUEST['page']; を $page = isset($_REQUEST['page']) ? $_REQUEST['page'] : ""; と置き換えればエラーは消えます。 三項演算子を使っています。 A ? B : C と書いたとき、AがtrueならB, falseならCという処理となります。 isset関数で配列インデックスが定義済かどうか確認し、 定義済みならその値を、未定義なら空文字""を$pageに代入しています。 詳しくは下記を参照ください。 http://qiita.com/mpyw/items/2f9955db1c02eeef43ea#1-2

adatruto
質問者

お礼

わかりやすい解説ありがとうございます。

その他の回答 (2)

  • yambejp
  • ベストアンサー率51% (3827/7415)
回答No.2

>Notice: Undefined index: page in C:\xampp\htdocs\shop\index.php on line 14 Noticeは「たいしたことないけど一応気にしておいて」というエラーです 「on line 14」とあるとおりプログラムの14行目でエラーが発生しています。 おそらく14行目は >$page = $_REQUEST['page']; だと思います。 これは、「$_REQUEST['page']」が存在しないので、存在しないデータを $pageに代入しようとしているために発生しています。 考え方は2つ (1)Noticeは気にする必要がないので、あえて無視する 具体的には「<?php」の直後の行に、以下を書いてNOTICEを表示させない error_reporting(E_ALL & ~E_NOTICE); (2)エラーになっている個所を修正する $page = isset($_REQUEST['page'])?$_REQUEST['page']:""; のどちらかでよいかと思います。

回答No.1

馬鹿でも初心者でも検索くらいできるよね? Notice: Undefined index: これをgoogleに入れただけで一番上にそのままの解決法が出てくるんだけど。

関連するQ&A

  • テーブルの情報が一部しか表示されません。(php)

    すべてのID分の提出状況を表示させたい("○"か"×")のですが、 id=1の提出状況しか表示されません。 テストデータはid=5までの5件を入力しています。 $recordSet2 = mysql_query('SELECT * FROM report'); をwhileにいれてみたり試行錯誤してみたのですが、上手くいきません。 ご指摘よろしくお願い致します。 プログラム <table width="70%"> <tr> <th scope="col"><bl>ID</bl></th> <th scope="col"><bl>教科名</bl></th> <th scope="col"><bl>課題名</bl></th> <th scope="col"><bl>担当教員</bl></th> <th scope="col"><bl>提出期限</bl></th> <th scope="col"><bl>再提出</bl></th> <th scope="col"><bl>再提出期限</bl></th> <th scope="col"><bl>提出状況</bl></th> </tr> <?php $recordSet = mysql_query('SELECT * FROM exercise ORDER BY id'); while ($table = mysql_fetch_assoc($recordSet)){ ?> <tr> <td><?php print(htmlspecialchars($table['id'])); ?></td> <td><?php print(htmlspecialchars($table['lessonname'])); ?></td> <td><?php print(htmlspecialchars($table['name'])); ?></td> <td><?php print(htmlspecialchars($table['teacher'])); ?></td> <td><?php print(htmlspecialchars($table['presentday'])); ?></td> <td><?php print(htmlspecialchars($table['represent'])); ?></td> <td><?php print(htmlspecialchars($table['representday'])); ?></td> <td><?php $recordSet2 = mysql_query('SELECT * FROM report'); $report = mysql_fetch_assoc($recordSet2); if ($table['lessonname'] == $report['lessonname'] && $table['name'] == $report['exercisename']) { if(eregi($member['name'], $report['upfile'])) { echo "○"; }else { echo "×"; } } ?></td> </tr> <?php } ?> </table>

    • ベストアンサー
    • PHP
  • テーブルの情報が一部しか表示されません。(php)

    すべてのID分の提出状況を表示させたい("○"か"×")のですが、 id=1の提出状況しか表示されません。 >>CODE $recordSet2 = mysql_query('SELECT * FROM report'); <<CODE をwhileにいれてみたり試行錯誤してみたのですが、上手くいきません。 ご指摘よろしくお願い致します。 プログラム >>CODE <table width="70%"> <tr> <th scope="col"><bl>ID</bl></th> <th scope="col"><bl>教科名</bl></th> <th scope="col"><bl>課題名</bl></th> <th scope="col"><bl>担当教員</bl></th> <th scope="col"><bl>提出期限</bl></th> <th scope="col"><bl>再提出</bl></th> <th scope="col"><bl>再提出期限</bl></th> <th scope="col"><bl>提出状況</bl></th> </tr> <?php $recordSet = mysql_query('SELECT * FROM exercise ORDER BY id'); while ($table = mysql_fetch_assoc($recordSet)){ ?> <tr> <td><?php print(htmlspecialchars($table['id'])); ?></td> <td><?php print(htmlspecialchars($table['lessonname'])); ?></td> <td><?php print(htmlspecialchars($table['name'])); ?></td> <td><?php print(htmlspecialchars($table['teacher'])); ?></td> <td><?php print(htmlspecialchars($table['presentday'])); ?></td> <td><?php print(htmlspecialchars($table['represent'])); ?></td> <td><?php print(htmlspecialchars($table['representday'])); ?></td> <td><?php $recordSet2 = mysql_query('SELECT * FROM report'); $report = mysql_fetch_assoc($recordSet2); if ($table['lessonname'] == $report['lessonname'] && $table['name'] == $report['exercisename']) { if(eregi($member['name'], $report['upfile'])) { echo "○"; }else { echo "×"; } } ?></td> </tr> <?php } ?> </table> <<CODE

    • ベストアンサー
    • PHP
  • phpのエラーについてです

    mysql上のデータをphpでブラウザに表示するコードを書いています。 下記のプログラムを実行した所 Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\xampplite\htdocs\shop\index.php on line 18 というようなエラーが表示されます。 本の通りに進めているので間違っていないはずなんですが・・ どこが成立していないのでしょうか??? <?php mysql_connect('localhost', 'root', '') or die(mysql_error()); mysql_select_db('mydb'); mysql_query('SET NAMES UTF8'); $recordSet = mysql_query('SELECT m.name, i.* FROM makers m, my_ items i WHERE m.id=i.maker_id ORDER BY id DESC'); ?> <table width="100%"> <tr> <th scope="col">ID</th> <th scope="col">メーカー</th> <th scope="col">商品名</th> <th scope="col">価格</th> </tr> <?php while ($table = mysql_fetch_assoc($recordSet)) { ?> <tr> <td><?php print(htmlspecialchars($table['id'])); ?></tb> <td><?php print(htmlspecialchars($table['name'])); ?></tb> <td><?php print(htmlspecialchars($table['item'])); ?></tb> <td><?php print(htmlspecialchars($table['price'])); ?></tb> </tr> <?php } ?> </table>

    • ベストアンサー
    • PHP
  • 「未定義の変数」の定義について(PHP)

    ●質問の主旨 添付画像の左端に Notice: Undefined index: page in C:\xampp\htdocs\shop\index.php on line 3 ということで、未定義の変数ということでおしらせが出ています。 この表示を消すためにはどうすれば良いでしょうか? ご存知のかた、ご教示願います。 ●質問の補足 下記のコードで言えば、 $page =$_REQUEST['page']; のうち、pageが定義されていないことが、表示の原因である気がします。 しかし、どこをどう書き換えれば、表示が消えるのかが分かりません。 ●参考文献 たにぐちまこと「よくわかるPHPの教科書」(P210)の index.phpファイル ●開発環境 windows8 xammp1.8.1 ●コード <?php require('dbconnect.php'); $page =$_REQUEST['page']; if ($page == '') { $page = 1; } $page = max($page, 1); //最終ページを取得する $sql = 'SELECT COUNT(*) AS cnt FROM my_items'; $recordSet = mysql_query($sql); $table = mysql_fetch_assoc($recordSet); $maxPage = ceil($table['cnt'] / 5); $page = min($page, $maxPage); $start = ($page - 1) * 5; $recordSet = mysql_query('SELECT m.name, i. * FROM makers m, my_items i WHERE m.id=i.maker_id ORDER BY id DESC LIMIT ' . $start .',5'); ?> <!DOCTYPE html> <html lang="ja"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link rel="stylesheet" type="text/css" href="style.css" /> <title>Webシステムをつくる</title> </head> <body> <div id="wrap"> <div id="head"> <h1>トップページ</h1> </div> <div id="content"> <p style="margin-top: 20px"> <table width="100%"> <tr> <th scope="col">ID</th> <th scope="col">メーカー</th> <th scope="col">商品名</th> <th scope="col">価格</th> </tr> <?php while ($table = mysql_fetch_assoc($recordSet)) { ?> <tr> <td><?php print(htmlspecialchars($table['id'])); ?></td> <td><?php print(htmlspecialchars($table['name'])); ?></td> <td><?php print(htmlspecialchars($table['item_name'])); ?></td> <td><?php print(htmlspecialchars($table['price'])); ?></td> </tr> <?php } ?> </table> <ul class="paging"> <?php if ($page > 1) { ?> <li><a href="index.php?page=<?php print($page - 1); ?>">前のページへ</a></li> <?php } else { ?> <li>前のページへ</li> <?php } ?> <?php if ($page < $maxPage) { ?> <li><a href="index.php?page=<?php print($page + 1); ?>">次のページへ</a></li> <?php } else { ?> <li>次のページへ</li> <?php } ?> </ul> </p> </div> <div id="foot"> <p><img src="images/txt_copyright.png" width="136" height="15" alt="(C) H2O Space. MYCOM" /></p> </div> </div> </body> </html>

    • ベストアンサー
    • PHP
  • 同じコードを使っているのにエラーはなぜ?

    ●質問の意味 先日、似たような質問をいたしました。 「未定義の変数」の定義について(PHP) http://okwave.jp/qa/q8060182.html それと同じようなコードを書いていますが、 エラーが出ます。なぜでしょうか? ご存知の方、よろしくお願いします。 ●質問の補足 下記のコードの3行目 $page = isset($_GET['page']) ? intval($_GET['page']) : 1; についてエラーが出ています。 コメントアウトしている //$page =$_REQUEST['page']; は、参考文献の方のコードですがこちらでもエラーが出ます。 ●参考文献 たにぐちまこと「よくわかるPHPの教科書」(P215)の update.phpファイル ●開発環境 windows8 xammp1.8.1 ●コード(update.php) <?php require('dbconnect.php'); //$page =$_REQUEST['page']; $page = isset($_GET['page']) ? intval($_GET['page']) : 1; if ($page == '') { $page = 1; } $page = max($page, 1); //最終ページを取得する $sql = 'SELECT COUNT(*) AS cnt FROM my_items'; $recordSet = mysql_query($sql); $table = mysql_fetch_assoc($recordSet); $maxPage = ceil($table['cnt'] / 5); $page = min($page, $maxPage); $start = ($page - 1) * 5; $recordSet = mysql_query('SELECT m.name, i. * FROM makers m, my_items i WHERE m.id=i.maker_id ORDER BY id DESC LIMIT ' . $start .',5'); ?> <!DOCTYPE html> <html lang="ja"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link rel="stylesheet" type="text/css" href="style.css" /> <title>Webシステムをつくる</title> </head> <body> <div id="wrap"> <div id="head"> <h1>トップページ</h1> </div> <div id="content"> <p style="margin-top: 20px"> <table width="100%"> <tr> <th scope="col">ID</th> <th scope="col">メーカー</th> <th scope="col">商品名</th> <th scope="col">価格</th> </tr> <?php while ($table = mysql_fetch_assoc($recordSet)) { ?> <tr> <td><?php print(htmlspecialchars($table['id'])); ?></td> <td><?php print(htmlspecialchars($table['name'])); ?></td> <td><?php print(htmlspecialchars($table['item_name'])); ?></td> <td><?php print(htmlspecialchars($table['price'])); ?></td> </tr> <?php } ?> </table> <ul class="paging"> <?php if ($page > 1) { ?> <li><a href="index.php?page=<?php print($page - 1); ?>">前のページへ</a></li> <?php } else { ?> <li>前のページへ</li> <?php } ?> <?php if ($page < $maxPage) { ?> <li><a href="index.php?page=<?php print($page + 1); ?>">次のページへ</a></li> <?php } else { ?> <li>次のページへ</li> <?php } ?> </ul> </p> </div> <div id="foot"> <p><img src="images/txt_copyright.png" width="136" height="15" alt="(C) H2O Space. MYCOM" /></p> </div> </div> </body> </html>

    • ベストアンサー
    • PHP
  • PHPでtableをループさせたい!

    【急募!】PHPでMysqlから取り出した値をHTMLのtableで出力したい。 うまくいかなくて困ってます。 今回で2度目の質問となります。今回も急いでおります。 現在、プログラムの勉強をして半年近くになります。本日3/3までに作成を完了しなければならず困っております。 何日か掛けて調べたのですが、まだまだ勉強不足の為に理解が出来ませんでした。 PHPで作成をしております。データベースから取り出した値をHTMLで作成したtableに出力後、tableをデータベースに入っている数だけループさせたいです。※イメージ画像あり おそらくwhile分でループさせれば良いとういうのは理解できるのですが、テーブル自体を増やすやりかたかが解りません。 while(データーベースの値をループさせてひとつずつ出力する。,テーブルも同じ数出力する) 全部取り出したら break で抜ける......となると思うのですが、書き方か解りません。 mysql_fetch_arrayというものもあるようですがまだ理解ができません。 答え合わせになってしまうのが恐縮でございますが、答え合わせのコードを頂けましたら嬉しいです。 まだ理解が浅いため、質問の内容に理解が出来なければ、ご連絡を頂きましたら改善改良をします。 お恥ずかしいですが、ソースを乗せさせて頂きますので宜しくお願い致します。 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <link href="css/style2.css" rel="stylesheet" type="text/css"> <title>管理画面</title> </head> <body> <div id="main"> <?php $dsn='mysql:dbname=motorlinks;host=localhost'; $user='root'; $password=''; $dbh=new PDO($dsn,$user,$password); $dbh->query('SET NAMES utf8'); $sql='SELECT code,gazou,name,shiyo,price,shiharai,first,sample,comment FROM pone WHERE 1'; $stmt=$dbh->prepare($sql); $stmt->execute(); print'製品一覧<br><br>'; print'<form method="post"action="pone_branch.php">'; ?> <?php while(true) { $rec=$stmt->fetch(PDO::FETCH_ASSOC); if($rec==false) { break; } print $rec['gazou']; print $rec['name']; print $rec['shiyo']; print $rec['price'].'円'; print $rec['shiharai']; print $rec['first']; print $rec['sample']; print $rec['comment']; print'<br>'; }?> <table width="800" border="1" cellpadding="0"> <?php print'<input type="radio"name="ponecode"value="'.$rec['code'].'">'; ?> <tr> <th colspan="2" rowspan="4" scope="col"><?php '<img src="gazou/burank.jpg" width="200" height="150" alt=""/>'; ?></th> <th width="162" height="4" scope="col">Product Name</th> <th width="162" height="4" scope="col">Specification</th> <th width="162" height="4" scope="col">Price</th> <th width="162" height="4" scope="col">Payment</th> </tr> <tr> <td height="63">&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> </tr> <tr> <th width="162" height="4" scope="col">First Order</th> <th width="162" height="4" scope="col">Sample</th> <th width="162" height="4" scope="col">Comment</th> <th width="162" height="4" scope="col">Contact</th> </tr> <tr> <td height=63">&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> </tr> </table> <?php print'<br>'; print'<input type="submit" name="disp" value="参照">'; print'<input type="submit" name="add" value="追加">'; print'<input type="submit" name="edit" value="修正">'; print'<input type="submit" name="delete" value="削除">'; print'</form>'; ?> <br> <a href="index_mo.html">トップメニューへ</a><br> </form> </div> </body> </html>

    • ベストアンサー
    • PHP
  • mysql データ表示

    下記のプログラムは詳細を選択すると選択されたデータをいま1件ずつ表示しているのですが 氏名と住所を編集できるようにテキストボックスにしたいまた選択されたデータを初期値として取りたいです 表示されるのですが入力できません どこにフォームなどの命令を入れればいいですか 全体表示のtop.php <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>一覧画面</title> </head> <body> <BLOCKQUOTE> <BR>一覧画面<BR><BR> <?php $con=mysqli_connect("localhost","root","admin","db_test"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $result = mysqli_query($con,"SELECT * FROM tbl_test"); echo "<table border='1'> <tr> <th>番号</th> <th>氏名</th> <th>住所</th> <th>詳細</th> </tr>"; while($row = mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['番号'] . "</td>"; echo "<td>" . $row['氏名'] . "</td>"; echo "<td>" . $row['住所'] . "</td>"; echo "<td><a href=\"exit.php?id=" . $row['番号'] . "\">詳細</a></td>"; echo "</tr>"; } echo "</table>"; mysqli_close($con); ?> <BR><BR><BR> <A HREF="http://localhost/regist.php"> <INPUT TYPE = "SUBMIT" VALUE = "新規登録"></A> </BLOCKQUOTE> </body> </html> 詳細表示の exit.php <html> <body> <table border='1'> <BR><BR> <tr> <th>番号</th> <th>氏名</th> <th>住所</th> </tr> <?php $id=(isset($_GET["id"]))?((int) $_GET["id"]):0; $con=mysqli_connect("localhost","root","admin","db_test"); $result = mysqli_query($con,"SELECT `番号`,`氏名`,`住所` FROM tbl_test where `番号`={$id}"); while($row = mysqli_fetch_array($result,MYSQLI_ASSOC)) { print "<tr>"; print "<td>".htmlspecialchars($row["番号"])."</td>"; print "<td>".htmlspecialchars($row["氏名"])."</td>"; print "<td>".htmlspecialchars($row["住所"])."</td>"; print "</tr>"; } ?> </table> <BR><BR> <A HREF="http://localhost/top.php"> <INPUT TYPE = "SUBMIT" VALUE = "一覧へ戻る"></A> </body> </html>

  • 30時間アカデミックPHP入門 実教出版

    お世話になります。30時間アカデミックPHP入門 実教出版を勉強中です。mac環境MAMPだとP191実習15で躓きます。サンプルコードを貼り付けてもSQLデータが読み込まれません。何故でしょうか? <?php require_once('./dbConfig.php'); $link = mysqli_connect(DB_SERVER, DB_USER, DB_PASS, DB_NAME); if ($link == null) { die("接続に失敗しました:" . mysqli_connect_error()); } mysqli_set_charset($link, "utf8"); $sql = "SELECT reserve_no, reserve_date, room_no, numbers, checkin_time, message, customer_name, customer_telno FROM reserve, customer WHERE reserve.customer_id = customer.customer_id "; $result = mysqli_query($link, $sql); ?> <!DOCTYPE html> <html lang="ja"> <head> <meta charset="UTF-8"> <link rel="stylesheet" href="./css/style.css" type="text/css"> <title>JIKKYO PENSION</title> </head> <body> <!-- ヘッダー:開始--> <header id="header"> <div id="pr"> <p>部活・サークル等のグループ利用に最適!アットホームなペンション!</p> </div> <h1><a href="./index.php"><img src="./images/logo.png" alt=""></a></h1> </header> <!-- ヘッダー:終了 --> <!-- メニュー:開始 --> <nav id="menu"> <ul> <li><a href="">本日</a></li> <li><a href="">本日以降</a></li> <li><a href="">過去</a></li> </ul> </nav> <!-- メニュー:終了 --> <!-- コンテンツ:開始 --> <div id="contents"> <h2>予約管理画面(本日)</h2> <p>各行の削除ボタンを押すことで、予約情報を削除することができます。</p> <table class="host"> <th> 宿泊日付 </th> <th>チェックイン<br>予定時間</th> <th>部屋番号</th> <th>顧 客 名</th> <th>代表者連絡先</th> <th>利用人数</th> <th>メッセージ</th> <th></th> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo "<tr>"; $rdate = date('Y-m-d', strtotime($row['reserve_date'])); echo "<td>{$rdate}</td>"; echo "<td>{$row['checkin_time']}</td>"; echo "<td>{$row['room_no']}</td>"; echo "<td>{$row['customer_name']}</td>"; echo "<td>{$row['customer_telno']}</td>"; echo "<td>{$row['numbers']}人</td>"; echo "<td>{$row['message']}</td>"; echo "<td><a class='submit_a' href='./ownerReserveDelete.php?rno={$row['reserve_no']}'>削除</a></td>"; echo "</tr>"; } ?> </table> <br> <a class="submit_a" href="ownerLogout.php">ログアウト</a> </div> <!-- コンテンツ:終了 --> <!-- フッター:開始 --> <footer id="footer"> Copyright c 2016 Jikkyo Pension All Rights Reserved. </footer> <!-- フッター:終了 --> <?php mysqli_free_result($result); mysqli_close($link); ?> </body> </html>

    • 締切済み
    • PHP
  • FC2のブログで HTML

    新規投稿した際に、画像のソース下にテーブルを配置したのですが、画像とテーブルの間に広い空白ができてしまいます。空白をなくすにはどのようにすればよいのでしょうか? <a href="http://blog-imgs-37.fc2.com/h/i/r/xxx/xxx-img600x448-1291282057iczrmy28164.jpg" target="_blank"><img src="http://blog-imgs-37.fc2.com/h/i/r/xxx/xxxi-img600x448-1291282057iczrmy28164s.jpg" alt="" border="0" width="119" height="89" /></a> <table width="400" border="1"> <tr> <th scope="col">価格A</th> <th scope="col">価格B</th> <th scope="col">価格C</th> </tr> <tr> <td>1,500</td> <td>2,000</td> <td>未</td> </tr> </table>

    • ベストアンサー
    • HTML
  • php 分割

    以前はmysql関数をページングを行ったのですが、今回はpdoにやりたいけど pdoに書き換えるやり方がわかりません また前回は前のページ、次のページだったのですが 15件中 1-10件表示 ○ページ表示 と行い <前 1 2 3 次>みたいにやりたいです <html> <head> <title>一覧画面</title> </head> <body> <br><br> <blockquote> 一覧画面 <br><br> <form action = "" method="GET"> <input type="hidden" name="event" value="find"> <input type="text" name="name"style ="font-size:20px;width: 400px; height: 40px"> <input type="submit" value="検索" style ="font-size:20px;width: 100px; height: 40px"> </form> <br><br> <?php if ($_GET) { // データがGETされていたら $event = isset($_GET['event']) ? $_GET['event'] : ''; // 取得 } $pdo = new PDO("mysql:dbname=db_test;host=localhost", "root", "admin"); $name=isset($_GET['name'])?$_GET['name']:""; $perpage=10; $page=isset($_GET['page'])?($_GET['page']*$perpage):0; $sql ="select * from tbl_test where 1 "; $sql.="and (0 "; $sql.="or `氏名` like concat('%',?,'%') "; $sql.="or `住所` like concat('%',?,'%') "; $sql.=") "; $sql.= " limit {$page},{$perpage}" ; $stmt = $pdo->prepare( $sql); $stmt->execute(array($name,$name)); $count = $stmt->rowCount(); if($count>0){ print "<table border=1>" ; print "<tr>"; print "<th>番号</th>"; print "<th>氏名</th>"; print "<th>住所</th>"; print "<th>操作</th>"; print "</tr>"; while($row = $stmt->fetch(PDO::FETCH_ASSOC)){ $ID = htmlspecialchars($row['番号']); $NAME = htmlspecialchars($row['氏名']); $ADDR = htmlspecialchars($row['住所']); echo "<tr> <td>$ID</td> <td>$NAME</td> <td>$ADDR</td> <td><a href='edit.php?番号=$ID'>修正</a> <a href='delete.php?番号=$ID'>削除</a></td></tr>"; print "</tr>"; }; print "</table>" ; }else{ print "該当するデータがありません"; } ?> このソースにどう命令を入れていいのかわからず困っています サンプルソースや指摘おねがいします

    • ベストアンサー
    • PHP

専門家に質問してみよう