index.phpでクエリをinfo.phpまで送りました。
それでinfo.phpでクエリをgetし、受け渡しができている状態です。
セレクトのところに入れましたが、ブラウザにはうまく表示しませんでした。
素人の考えだとクエリを渡せばうまくIDごとに詳細が表示してくれるが、実際こういうコードを書いても表示しなかったです。
エラーもなにもなく、空白でした。
回答よろしくお願いいたします。
index.php
php
1$result = mysql_query('SELECT id,name FROM user'); 2if (!$result) { 3 die('クエリーが失敗しました。'.mysql_error()); 4} 5 6 7 8while ($row = mysql_fetch_assoc($result)) { 9 ?> 10 11 <tr> 12 <td><?php print(htmlspecialchars($row['id']));?></td> 13 <td><?php print(htmlspecialchars($row['name']));?></td> 14 <td id="ss"><a href="info.php?id=<?php print $row['id']; ?>">詳細</a></td> 15</tr> 16<?php 17} 18$close_flag = mysql_close($link);
info.php
php
1<?php 2//ここからです 3$id = $_GET['id']; 4$result = mysql_query('SELECT * FROM user WHERE id="$id"'); 5mysql_real_escape_string($id); 6 7if (!$result) { 8 die('クエリーが失敗しました。'.mysql_error()); 9} 10 11while ($row = mysql_fetch_assoc($result)) { 12 13 14 ?> 15<table border="1" cellspacing="10" width="200px"> 16 <tr> 17 <th>日付</th> 18 <td><?php 19 print date('Y年n月j日 H時i分s秒', strtotime($row['ins_date']));?></td> 20 </tr> 21 <tr> 22 <th>ID</th> 23 <td><?php print(htmlspecialchars($row['id']));?></td> 24 </tr> 25 <tr> 26 <th>入力値</th> 27 <td><?php print(htmlspecialchars($row['name']));?></td> 28 </tr> 29 </table> 30 31 32<?php 33} 34mysql_free_result($result); 35$close_flag = mysql_close($link); 36 37?>
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。