来自带有选择字段的html表单的Php响应

I have a order form but it not working as it should The form has 3 select firlds with values from 1 to 5. Field 1 is the Box count, Field 2 is the Cake count, and the 3rd is candies count. So what i need is to make the order for to work as : If i select 2 boxes and 2 cakes i want to get the results for 2 boxes each box contain one cake.

The code that i have is working with the boxes count but it returns the same value foe cakes and cadies in each box. If i select 2 boxes and 4 cakes it return the response for 2 boxes each box with 4 cakes ( and i dont want this. )

  $Cake_count= intval($_POST["Cake"]);
    $Candy_count= intval($_POST["Candy"]);
    $Box_count= intval($_POST["Box"]);

    $box_array = array();
    for($i=0;$i<$Box_count;$i++)
    {
        for($j=0;$j<$Cake_count;$j++)
        {
            $box_array[$i][] = array("paxType" => "Cake");
        }  

        for($k=0;$k<$Candy_count;$k++)
        {
            $box_array[$i][] = array("paxType" => "Candy");
        }     
    }

Could you please help me fix the code so it can return the response as i need ?

Form is:

<form action="form.php" method="post">
                                <div class="row">                                
                                    <div class="form-group col-sm-6 col-md-3">
                                        <div class="row">
                                            <div class="col-xs-4">
                                                <label>Camere</label>
                                                <div class="selector">
                                                    <select name="Box" class="full-width">
                                                        <option value="1">1</option>
                                                        <option value="2">2</option>
                                                        <option value="3">3</option>
                                                        <option value="4">4</option>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="col-xs-4">
                                                <label>Cake</label>
                                                <div class="selector">
                                                    <select name="Cake" class="full-width">
                                                        <option value="1">1</option>
                                                        <option value="2">2</option>
                                                        <option value="3">3</option>
                                                        <option value="4">4</option>
                                                        <option value="5">5</option>
                                                        <option value="6">6</option>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="col-xs-4">
                                                <label>Candy</label>
                                                <div class="selector">
                                                    <select name="Candy" class="full-width">
                                                        <option value="0">0</option>
                                                        <option value="1">1</option>
                                                        <option value="2">2</option>
                                                        <option value="3">3</option>
                                                        <option value="4">4</option>
                                                    </select>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </form>

Expected action with few examples:

------------------------------------------
Request : Box - 2, Cake -2
Response: Box 1 - 1 cake; Box 2- 1 Cake.
------------------------------------------
Request : Box - 2, Cake -4
Response: Box 1 - 2 cakes; Box 2 - 2 Cakes.
------------------------------------------
Request : Box - 2, Cake -3
Response: Box 1 - 2 cakes; Box 2 - 1 Cakes.
------------------------------------------
Request : Box - 3, Cake -6
Response: Box 1 - 2 cakes; Box 2 - 2 Cakes; Box 3 - 2 Cakes.
------------------------------------------------------------

etc Rules:

  • No more than 3 cakes in one box;
  • Somehow split the impar numbers into a logical way as my above examples.