I am making a survey form with PHP and HTML. I have made a page with checkboxes for each question. Now I want to check whether at least one checkbox is checked (it can be multiple) for each question. 

I have tried to put the 'required' attributes for each checkbox, but then it required user to check all the checkboxes for each question before submission. What should I do? The following are my codes:

```
<?php 
$number = 0;
foreach($questions as $question){
   $number = $number + 1;         
   foreach($choices as $choice){
?>

  <input type="checkbox" name="<?php echo 'q'.$number.'checkbox_ans[]'; ?>" value="<?php echo $choice->id; required ?>"><?php echo $choice->getTitle(); ?>

<?php    
    }
}
?>

```

It should be able to detect whether at least one checkbox is checked for each question before submission.