Jump to content

Recommended Posts

Hi all,

i am trying to process a simple checkbox form within a while statement.
form works fine but im having trouble naming the range so that selections can be retrieved

code is

while($checkbox = mysql_fetch_array($qry))
{
echo "<input type='checkbox' name='$checkbox[field]'>" . " " . $checkbox[going] . "<br/>" ;
}

when i try and retrieve name value in page where form sends information i am having problems.

can you suggest how to name each checkbox - there could be any number of checkboxes from 1 to 500?

many thanks.
Link to comment
https://forums.phpfreaks.com/topic/12261-help-with-form-using-php/
Share on other sites

Normally you'd use name='blah[]' and then retrieve it using $_REQUEST['blah'] but since you're using a query, I would assume that's not what you want. My first suggestion would be to use _ instead of a space as a separator between your field and going values as that some values may have a tailing or leading space, causing problems when you try and explode() the values (of course, they might have trailing or leading underscores in which case use something silly like ===?^$;===). Also, checkboxes that have been checked will send as data but unchecked checkboxes will not send instead of having the value of false which would be expected. If you didn't know about this behaviour then that may be your problem.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.