I have an HTML table with radio buttons. The table displays fine but I do not know how to get the selected value into a database table. I am using PHP and MYSQL database.
Below is the code for the table
<?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>
Note: I Am yet to create the update_account.php. Just want to figure out how to get the buttons value from the table and store in the permission column of the groups table.