0
我有一個帶單選按鈕的HTML表格。表格顯示正常,但我不知道如何將選定的值存入數據庫表格。我正在使用PHP和MYSQL數據庫。將HTML表格中的單選按鈕值存儲到MySQL表格
下面是表
<?php
$stmt = $dbh->prepare("SELECT m.member_id , m.username , m.email , g.permission FROM members m INNER JOIN members_groups q
ON m.member_id = q.member_id INNER JOIN groups g on q.group_id = g.group_id ");
?>
<table>
<caption>List data from mysql</caption>
<tr>
<th class="center"><strong>Name</strong></th>
<th class="center"><strong>Email</strong></th>
<th class="center"><strong>Admin</strong></th>
<th class="center"><strong>Account Manager</strong></th>
<th class="center"><strong>delete</strong></th>
</tr>
<?php
if($stmt->execute()){
// output data of each row
while($rows = $stmt->fetch(PDO::FETCH_ASSOC)){ ?>
<tr>
<td class="center"><?php echo $rows['username']; ?></td>
<td class="center"><?php echo $rows['email']; ?></td>
<td class="center">
<input type='radio' id='admin' name=<?php echo $rows['username']; ?> value="admin"
<?php echo ($rows['permission']== 31)?'checked':'' ?>></input>
</td>
<td class="center">
<input type='radio' id='ac_manager' name=<?php echo $rows['username']; ?> value="ac_maneger"
<?php echo ($rows['permission']== 1)?'checked':'' ?> ></input> </td>
<td class="center" >
<a href="javascript:if(confirm('Are you sure you want to delete?'))
{ location.href='update_account.php?id=<?php echo $rows['member_id']; ?>'; }">delete</a>
</td>
</tr>
<?php
}
}
?>
</table>
注意代碼:我還沒有建立update_account.php。只是想弄清楚如何從表中獲取按鈕值並存儲在組表的權限列中。
成員鍵你的單選按鈕在哪裏? –
[PHP表單處理單選按鈕]的可能重複(http://stackoverflow.com/questions/5031768/radio-buttons-with-php-form-handling) – DontVoteMeDown