Heya stackoverflowers,
I've got a question about databases and checkboxes..
I've got a table looking like:
Website is looking like:
At the bottom of the page I also have a button, so when I submit the checked checkboxes will be updated to 1 or 0 in the database. (True or false)
So when I click on the 3rd checkbox under trained, it will update the trained column in the database with a user/room id of '3583'. (ID is shown right of the screen)
Code:
<form class='verwerkInfo' method='post' action='<?php echo $_SERVER['PHP_SELF']; ?>?license=6'>
<td>
<?php if($room->trained == 1) { ?> <input type='checkbox' name="<?php echo $room->room_id; ?>" checked> <?php echo "Y"; } else{ ?> <input type='checkbox' name="<?php echo $room->room_id; ?>"> <?php echo "N"; }?> </td>
<Td><?php if($room->active == 1) { ?> <input type='checkbox' name="<?php echo $room->room_id; ?>" checked> <?php echo "Active"; } else { ?> <input type='checkbox' name="<?php echo $room->room_id; ?>" <?php echo "Inactive"; } ?>
</td>
<Td><?php echo $room->configuration; ?></td>
<td><?php echo $room->room_id; ?></td>
<td><?php var_dump($room->user_id); }?></td>
</tr>
So I guess i have a problem in the names, of the checkboxes..
The query is looking like:
$trainedQuery = "UPDATE room_users
SET trained = 1
WHERE user_id = $room->user_id";
The $room->user_id
is referring to the user_id in the database...
Please help me on this problem, please do not comment like your code is bad or something:)
Thanks in advance!!
Aucun commentaire:
Enregistrer un commentaire