StefanRSA Posted August 24, 2009 Share Posted August 24, 2009 I am building dynamic fields for a form. I need a multiple value check box and I get the values from my db. else if ($ftype == 'select'){ $value=explode(", ", $fval); for($i = 0; $i < count($value); $i++){ $val2 .= '<input type="checkbox" name="'.$fname.'" value="'.$value[$i].'">'.$value[$i].'<br>'; } The field display fine on my page, but when I select more than one checkbox, only one gets posted???? My post value is as follow: $query = mysql_query("SELECT * FROM field_name WHERE sub_id = '$adsubcat'") or die(mysql_error()); while($rows = mysql_fetch_array($query)){ $ftype= $rows['field_type']; $ftitle= $rows['field_title']; $f_id = $rows['id']; $fname= $rows['field_name']; $fcomp= $rows['compulsory']; $fval= $rows['val']; $fhelp= $rows['help']; $fid= $rows['help']; ///Posted field start here $postedfield=trim($_POST[$fname]); } Can anybody please help? Link to comment https://forums.phpfreaks.com/topic/171601-solved-_post-dont-pull-checkbox-values/ Share on other sites More sharing options...
TeNDoLLA Posted August 24, 2009 Share Posted August 24, 2009 You need to have the name attribute as an array in your html name. So you have to add square brackets in the name in output when creating the form. <input type="checkbox" name="myCheckboxes[]" value="" /> <input type="checkbox" name="myCheckboxes[]" value="" /> <input type="checkbox" name="myCheckboxes[]" value="" /> Link to comment https://forums.phpfreaks.com/topic/171601-solved-_post-dont-pull-checkbox-values/#findComment-904890 Share on other sites More sharing options...
StefanRSA Posted August 24, 2009 Author Share Posted August 24, 2009 TY TenDolla, Now... Even I know how to do this! LOL!!!! Link to comment https://forums.phpfreaks.com/topic/171601-solved-_post-dont-pull-checkbox-values/#findComment-904891 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.