前提
PHPとMySQLを用いてデータ管理画面を作成しています。
実現したいこと
画面上(list.php)に表示されているデータベースの編集アイコンをクリックした際に
クリックしたIDのデータを編集ページ(update_form.php)のinputタグに表示されるようにしたい。
発生している問題・エラーメッセージ
問題としては、そもそもクリックしたIDのデータが引き込めているのかどうかが分からないため、次にやりたいことに進めない事です。
該当のソースコード
$resultの中身(データベース)
+----+----------+------+---------------------+---------------------+ | id | username | mail | created_at | modeified_at | +----+----------+------+---------------------+---------------------+ | 1 | あ | a | 2022-08-28 21:33:13 | 2022-08-28 21:33:13 | | 2 | い | i | 2022-08-28 21:34:10 | 2022-08-28 21:34:10 | | 3 | う | u | 2022-08-28 21:35:06 | 2022-08-28 21:35:06 | | 4 | え | e | 2022-08-28 21:35:21 | 2022-08-28 21:35:21 | | 5 | お | o | 2022-08-28 21:35:38 | 2022-08-28 21:35:38 | | 6 | か | ka | 2022-08-28 21:35:56 | 2022-08-28 21:35:56 | | 7 | き | ki | 2022-08-28 21:36:40 | 2022-08-28 21:36:40 | | 8 | く | ku | 2022-08-28 21:36:50 | 2022-08-28 21:36:50 | | 9 | け | ke | 2022-08-28 21:37:01 | 2022-08-28 21:37:01 | | 10 | こ | ko | 2022-08-28 21:37:09 | 2022-08-28 21:37:09 | | 11 | さ | sa | 2022-08-28 21:37:18 | 2022-08-28 21:37:18 | | 12 | し | si | 2022-08-28 21:37:29 | 2022-08-28 21:37:29 | | 13 | す | su | 2022-08-28 21:37:44 | 2022-08-28 21:37:44 | | 14 | せ | se | 2022-08-28 21:37:54 | 2022-08-28 21:37:54 | | 15 | そ | so | 2022-08-28 21:38:03 | 2022-08-28 21:38:03 | | 16 | た | ta | 2022-08-28 21:38:12 | 2022-08-28 21:38:12 | | 17 | ち | ti | 2022-08-28 21:38:25 | 2022-08-28 21:38:25 | | 18 | つ | tu | 2022-08-28 21:38:35 | 2022-08-28 21:38:35 | | 19 | て | te | 2022-08-28 21:38:43 | 2022-08-28 21:38:43 | | 20 | と | to | 2022-08-28 21:38:53 | 2022-08-28 21:38:53 | +----+----------+------+---------------------+---------------------+
PHP(list.php)
1<table style="border-collapse: separate;"> 2 <tr> 3 <th class="id">ID</th> 4 <th class="name">NAME</th> 5 <th class="mail">MAIL</th> 6 <th class="up">EDIT</th> 7 <th class="dele">DELETE</th> 8 </tr> 9 <?php foreach ($result as $list) { ?> 10 <tr> 11 <td class="id"><?php echo htmlspecialchars($list["id"]); ?></td> 12 <td class="name"><?php echo htmlspecialchars($list["username"]); ?></td> 13 <td class="mail"><?php echo htmlspecialchars($list["mail"]); ?></td> 14 <td class="up"><a href="update_form.php?id=<?php echo htmlspecialchars($list['id']); ?>"><i class="fas fa-file-alt"></i></a></td> 15 <td class="dele"><a href="delete.php?id=<?php echo htmlspecialchars($list['id']); ?>" onclick="return confirm('このレコードを削除します。よろしいでしょうか?')"><i class="fas fa-trash-alt"></i></a></td> 16 </tr> 17 <?php } ?> 18 </table>
PHP(update_form.php)
1<?php 2header("X-FRAME-OPTIONS: DENY"); 3$name = $_POST['username']; 4$mail = $_POST['mail']; 5$entry = ('select * from users where id order by desc'); 6$id = intval($_GET["id"]); 7?>
update_form.php
1<html> 2<div class="form_input"> 3 <div class="username"> 4 <label>ユーザーネーム</label> 5 <input type="text" name="username" value="?"> 6 </div> 7 <div class="mail"> 8 <label>メールアドレス</label> 9 <input type="text" name="mail" value="?"> 10 </div> 11</div> 12</html>
勉強中のため、初歩的かつ不足のある質問かと思いますがご回答いただけると幸いです。
回答2件
あなたの回答
tips
プレビュー
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。
また依頼した内容が修正された場合は、修正依頼を取り消すようにしましょう。