私は各データベースエントリに対して編集ボタンを持っていたいと思います。ユーザーが編集をクリックすると、それだけでエントリが取得されます。私は<input type="hidden" name="userid" value=...>
のような隠された入力を使用しようとしましたが、実際にどこに置くべきか、それがどのように役立つかはわかりません。ボタンクリックでIDを渡すユーザーごと
それも視覚化することができるので、私はテーブルの写真を添付しました。
私はあなたが私を助けることを願って、あなたが知っている必要があり、他の情報がありますならば、ちょうど私がしてください知っています。
<?php
include 'dbConnect.php';
echo '<table border="1" cellpadding="1" cellspacing="1" width="90%" style="margin: 0 auto">';
echo '<tr class="allUsers">';
echo '<th>Username</th>';
echo '<th>First name</th>';
echo '<th>Last name</th>';
echo '<th>Email</th>';
echo '<th>Year group</th>';
echo '<th>Subject 1</th>';
echo '<th>Subject 2</th>';
echo "<th>Subject 1's teacher</th>";
echo "<th>Subject 2's teacher</th>";
echo '<th>Privilege</th>';
echo '<th></th>';
echo '</tr>';
$getUsers = mysqli_query($connection, "SELECT * FROM users");
while($users=mysqli_fetch_assoc($getUsers)){
echo '<form method="post" action="">';
echo '<tr>';
echo '<td>'.$users['username'].'</td>';
echo '<td>'.$users['first_name'].'</td>';
echo '<td>'.$users['last_name'].'</td>';
echo '<td>'.$users['email'].'</td>';
echo '<td>'.$users['year_group'].'</td>';
echo '<td>'.$users['subject'].'</td>';
echo '<td>'.$users['subject2'].'</td>';
echo '<td>'.$users['teacher'].'</td>';
echo '<td>'.$users['teacher2'].'</td>';
echo '<td>'.$users['is_admin'].'</td>';
echo '<td><button name="editUser">Edit</button></td>';
echo '</tr>';
echo '</form>';
}
if (isset($_POST['editUser'])){
$username = $_SESSION['name'];
// ....
}
}
echo '</table>';
?>
あなたは右のあなたのテーブルでそれを編集したり、別のページにユーザーを持って帰りたいと思いますか? – maximedubois
同じページで、おそらく他のエントリを隠すか、それが簡単な場合は別のページだけを隠すことによって。 – leveeee