That's what she said
New member
Hey. SO i have an html form that has about 15 checkboxes on it...I know it would be easy to just name each checkbox its own name (check1, check2 etc) but that would be kind of tedious...
right now I have it like: <input type="checkbox" name="Descr[]" value="Breakfast" /> (of course the value is different in each one), but the name is the same..
i know how to go thru the boxes...but like...is there a way to assign 'breakfast' to a certain spot in the array?
ie. $Descr[1] = breakfast
$Descrt[2] = Lunch
where lunch and breakfast are the value ="" field?
This is what I have so far...all it does is goes thru them and adds all the checked boxes to the string:
if(isset($_POST['Add'])){
if(isset($_POST["Descr"])) {
$Descr = $_POST["Descr"];
} else {
$Descr=array();
}
for ($i="0"; $i<count($Descr); $i++) {
if($Descr[$i] != null){
$q=$q.$Descr[$i].", ";
}
}
//echo substr($q,0,strlen($q)-2);
}
?>
Which is good for when I need to do my sql query...but for now I just need to check which ones are checked, and if they are checked perform an operation.
any help would be great.
Thanks,
Paul
right now I have it like: <input type="checkbox" name="Descr[]" value="Breakfast" /> (of course the value is different in each one), but the name is the same..
i know how to go thru the boxes...but like...is there a way to assign 'breakfast' to a certain spot in the array?
ie. $Descr[1] = breakfast
$Descrt[2] = Lunch
where lunch and breakfast are the value ="" field?
This is what I have so far...all it does is goes thru them and adds all the checked boxes to the string:
if(isset($_POST['Add'])){
if(isset($_POST["Descr"])) {
$Descr = $_POST["Descr"];
} else {
$Descr=array();
}
for ($i="0"; $i<count($Descr); $i++) {
if($Descr[$i] != null){
$q=$q.$Descr[$i].", ";
}
}
//echo substr($q,0,strlen($q)-2);
}
?>
Which is good for when I need to do my sql query...but for now I just need to check which ones are checked, and if they are checked perform an operation.
any help would be great.
Thanks,
Paul