list.phpページからどのタスクを選択しているのかをわかるようにして、そのタスクの編集または削除画面へ飛べるようにしたいです。list.phpはindex.htmlをもとに作成しました。
前提
todoappを作成しています。写真のようなデザインからどのタスクを選択しているのか、そのタスクの編集または削除画面に飛べるようにしたいです。
使用している教材ではラジオボタンを選択し飛べるようにしているのですが、ラジオボタンを制作するとindex.htmlのようなデザインにはなりませんでした。index.htmlのようなデザインから指定する場合はどのようにすればよろしいでしょうか?方法や参考になるサイトを教えてくださるとうれしいです。
発生している問題・エラーメッセージ
どのタスクを選択しているのかを示す方法が分かりません。
該当のソースコード
php
1list.php 2<!doctype html> 3<html lang="ja"> 4<head> 5 <meta charset="UTF-8"> 6 <meta name="viewport" 7 content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> 8 <meta http-equiv="X-UA-Compatible" content="ie=edge"> 9 <title>List Page</title> 10</head> 11<body> 12 13<h1> 14 ToDo List Page 15</h1> 16<form action="newtask.php"> 17 <button type="submit" style="padding: 10px;font-size: 16px;margin-bottom: 10px">New Todo</button> 18</form> 19<table border="1"> 20 <colgroup span="4"></colgroup> 21 <tr> 22 <th>ID</th> 23 <th>タイトル</th> 24 <th>内容</th> 25 <th>作成日時</th> 26 <th>編集</th> 27 <th>削除</th> 28 </tr> 29<?php 30try { 31$dbn = 'mysql:dbname=posts;host=localhost;charset=utf8'; 32$user = 'root'; 33$password = ''; 34$dbh = new PDO($dbn, $user, $password); 35$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 36 37$sql = 'SELECT * FROM posts'; 38$stmt = $dbh->prepare($sql); 39$stmt->execute(); 40 41$dbh = null; 42echo '<form method="post" action="newtask_branch.php">'; 43while (true) { 44 $rec = $stmt->fetch(PDO::FETCH_ASSOC); 45 if ($rec == false) { 46 break; 47 } else { 48 echo '<input type="radio" name="newtaskcode" value="'.$rec['ID'].'">'; 49 echo '<td>'. $rec['ID']. '</td>'; 50 echo '<td>'. $rec['title'].'</td>'; 51 echo '<td>'. $rec['content']. '</td>'; 52 echo '<td>'. $rec['created_at']. '</td>'; 53 echo '<td> <input type="submit" name="edit" value="編集する"> </td>'; 54 echo '<td><input type="submit" name="delete" value="削除する"></td>'; 55 echo '<br>'; 56 } 57} 58echo '</form>'; 59} catch(Exception $e) { 60 $e->getMessage(); 61 exit(); 62} 63 64?> 65</table> 66</body> 67</html>
試したこと
教材通りラジオボタンを使用してみるとデザインが崩れてしまいました。

バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2023/02/16 19:39