Jump to content


PHP Form

  • Please log in to reply
2 replies to this topic

#1 JackJack

  • Members
  • PipPipPip
  • Advanced Member
  • 38 posts

Posted 13 April 2006 - 04:16 PM

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.

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";

Please help

Thank You

#2 ober

  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 13 April 2006 - 05:34 PM

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.

Info: PHP Manual

#3 jworisek

  • Members
  • PipPipPip
  • Advanced Member
  • 112 posts

Posted 13 April 2006 - 05:38 PM

try this:

if (/*allowed*/){
else{/*not allowed*/

echo "<input type='checkbox' name='option$member[id]' $checked> $member[display_name] ($member[clan_bank])<br>";

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users