JackJack Posted April 13, 2006 Share Posted April 13, 2006 Im using mysql and php to create the details for the checkboxes but i don't know what to do to get the selected ones. Also i would like to have two buttons on the form.Im trying to create a list of people which will have access to a bank. The admin can change these and no one else. I want it so it changes the status of the people who she/he ticked on the checkboxes to/from allow and disallow. [code]echo "<a href=clan.php?action=changebank target=mainframe><u>Change Bank Access</u></a>";if($action == changebank){echo "<br><br>Select Members:<br>"; $members1 = mysql_query("select * from `players` where `clan_name` = '$clan[name]'order by `clan_bank` asc"); while($member = mysql_fetch_array($members1)) {echo "<form>";echo "<input type='checkbox' name='option$member[id]' > $member[display_name] ($member[clan_bank])<br>";echo "<a href=clan.php?action=allow target=mainframe>Allow</a>";echo "</form>";}if($action == allow){if($option$member[id] == on){mysql_query("UPDATE players set clan_bank=Yes where id='$member[id]'");echo "You updated bank access";}}} }[/code] Please helpThank You Quote Link to comment Share on other sites More sharing options...
ober Posted April 13, 2006 Share Posted April 13, 2006 Why are you opening and closing the form each time you display a checkbox? That's not going to work.Also, to have 2 buttons that perform a specific submit operation, you're going to have to use JavaScript.To answer the first question, if you have a field that is set to 0 or 1 depending on whether or not they're allowed, you just need to check for that condition when doing the echo of the record.If you gave us a link or explained the problem a little better, we can help you more. Quote Link to comment Share on other sites More sharing options...
jworisek Posted April 13, 2006 Share Posted April 13, 2006 try this:[code]if (/*allowed*/){ $checked="checked=\"checked\"";else{/*not allowed*/ $checked="";}echo "<input type='checkbox' name='option$member[id]' $checked> $member[display_name] ($member[clan_bank])<br>";[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.