Jump to content

help with form using php


bagnallc

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.

Archived

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

×
×
  • 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.