HELP! Adding up Arrays or $variables after submit from a checkbox form. Thanks

Hello,

Thanks for taking the time to look at my code. I need help regarding a numerical count of $var after I press the submit button for my form. Here is the code below:

<?php $Aconite[0] = 1; $Aconite[1] = 1; ?>

/* php */

Choose Rubrics to Help Find the Remedy:

Mind - Anger(Irascibility)
Mind - Anger
<?php if (isset($_POST['submit'])) { $rubric = $_POST["rubric"]; $how_many = count($rubric); echo 'Number of Rubrics Chosen: '.$how_many.'

'; if ($how_many>0) { echo 'You chose the following rubrics:
'; } for ($i=0; $i<$how_many; $i++) { echo ($i+1) . '- ' . $rubric[$i] . '
'; } echo "

"; }

$result = count($Aconite);
echo ($result);
?>

*/ End php */

Basically I have a checkbox form that has two mental conditions: Mind (Anger) and Mind Anger(Irascibility). WIth these two rubrics there will be multiple remedies under the rubrics. Right now I have Aconite declared as a variable. My problem is say the person only checks the box Mind (Anger), the remedy Aconite should be counted and displayed as “1”, say they pick both rubrics Mind(Anger) and Mind Anger(Irascibility), then aconite is also listed under this rubric and the count should be 2 instead of 1. My goal was to add more rubrcis with multiple remedies under them and just needed to know how to add up all the remedies if the user checks a box that has the remedy listed under it.

Thanks you so much for your help,

Cody

Sponsor our Newsletter | Privacy Policy | Terms of Service