Jump to content

Archived

This topic is now archived and is closed to further replies.

JackJack

PHP Form

Recommended Posts

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 help


Thank You

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.