bagnallc Posted June 17, 2006 Share Posted June 17, 2006 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 retrievedcode 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. Quote Link to comment https://forums.phpfreaks.com/topic/12261-help-with-form-using-php/ Share on other sites More sharing options...
klaroen Posted June 17, 2006 Share Posted June 17, 2006 don't realy understand the request :pbut:shouldn't it be $checkbox['field'] and $checkbox['going'] with the '' signs?I guess so... Quote Link to comment https://forums.phpfreaks.com/topic/12261-help-with-form-using-php/#findComment-46780 Share on other sites More sharing options...
Fyorl Posted June 17, 2006 Share Posted June 17, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/12261-help-with-form-using-php/#findComment-46783 Share on other sites More sharing options...
bagnallc Posted June 17, 2006 Author Share Posted June 17, 2006 managed to fix this now. many thanks for all your helpsorry for stupid question Quote Link to comment https://forums.phpfreaks.com/topic/12261-help-with-form-using-php/#findComment-46789 Share on other sites More sharing options...
Fyorl Posted June 17, 2006 Share Posted June 17, 2006 [code]echo "<input type='checkbox' name='check[]' value='" . (isset($checkbox['field']) ? $checkbox['field'] : $checkbox['going']) . "' />";[/code] Quote Link to comment https://forums.phpfreaks.com/topic/12261-help-with-form-using-php/#findComment-46790 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.