商店服务以及彼此相关的活动和周期性

时间:2018-09-05 10:24:31

标签: php html sql

HTML

<form action="htmlindex.php" method = "post">

    <input type="checkbox" name="arr[1][service]" value="Income tax" id="service-1" >

    1Income tax   
    <br>

    <div class="service_options_1" style="display: none;">

        <input type="checkbox" name="arr[1][activity][]" value="Return Filing 
        ">1Return Filing 
        <br>
        <input type="checkbox" name="arr[1][timeperiod][]" value="monthly">monthly
        <input type="checkbox" name="arr[1][timeperiod][]" value="Quarterly
        ">Quarterly

        <br>

        <input type="checkbox" name="arr[1][activity][]" value="Revised Return Filing
        ">2Revised Return Filing
        <br><input type="checkbox" name="arr[1][timeperiod][]" value="monthly">monthly<input type="checkbox" name="arr[1][timeperiod][]" value="Quarterly
        ">Quarterly


   </div>
    <br>



    <input type="checkbox" name="arr[2][service]" value="TDS" id="service-2" >

    2TDS    
    <br>

    <div class="service_options_2" style="display: none;">
        <input type="checkbox" name="arr[2][activity][]" value="25form
        ">25Form
        <br>
        <input type="checkbox" name="arr[2][timeperiod][]" value="monthly">monthly
        <input type="checkbox" name="arr[2][timeperiod][]" value="Quarterly
        ">Quarterly

        <br>
        <input type="checkbox" name="arr[2][activity][]" value="Department Vist 
        ">26Department Vist 
        <br>
        <input type="checkbox" name="arr[2][timeperiod][]" value="monthly">monthly
        <input type="checkbox" name="arr[2][timeperiod][]" value="Quarterly
        ">Quarterly

        <br>
        <input type="checkbox" name="arr[2][activity][]" value="Lower Deduction Application 
        ">31Lower Deduction Application 
        <br><input type="checkbox" name="arr[2][timeperiod][]" value="monthly">monthly<input type="checkbox" name="arr[2][timeperiod][]" value="Quarterly
        ">Quarterly
        <input type="checkbox" name="arr[2][timeperiod][]" value="Yearly
        ">Yearly
        <input type="checkbox" name="arr[2][timeperiod][]" value="Random">Random<br> 
  </div>





    <br>
    <input type="checkbox" name="arr[3][service]" value="GST" id="service-3" >

    3GST    
    <br>

    <div class="service_options_3" style="display: none;">
        <input type="checkbox" name="arr[3][activity][]" value="Tax Payment
        ">29LUT Application 
        <br><input type="checkbox" name="arr[3][timeperiod][]" value="monthly">monthly
        <input type="checkbox" name="arr[3][timeperiod][]" value="Quarterly
        ">Quarterly
        <input type="checkbox" name="arr[3][timeperiod][]" value="Yearly
        ">Yearly
        <input type="checkbox" name="arr[3][timeperiod][]" value="Random">Random<br><br>

   </div>

 <br>
<input type ="hidden" name="serviceactivity">
<input type="submit" name="submit" value="Submit">

</form>

代码的输出是 output image

当我显示或存储相关活动或时间段时,我选择的所有活动重复的时间段

我用于存储或显示数据的代码是

<?php
if(isset($_POST['submit']))
{
    foreach($_POST['arr'] as $input)
    {
        $ser = $input['service'];
        foreach($input['activity'] as $act)
        {

            $query = "insert into serviceactmap(service,activity)values('$ser','$act')";
            $conn->query($query);
            foreach($input['timeperiod'] as $time)
            {

               $sql = "insert into acttimemap(activity,timepriod)values('$act','$time')";
               $conn->query($sql);
            }


        }



    }
}
?>

在我的代码中,当我选择任何服务和活动时,服务和活动将正确存储,但是当我选择与任何活动相关的任何时间段时,对于所有活动重复所有选定的活动

例如

  1. 当我选择任何TDS-> 25form->每月,每季度
  2. 和TDS-> 31降低费用申请->每月,每年

然后我的输出是

  • TDS-> 25form->每月,每季度,每月,每年
  • TDS->降低费用申请表->每月,每季度,每月,每年

我的预期输出是

  • Tds-> 25form->每月-> 25form->季度
  • Tds->降低费用申请->每月->降低费用申请->每年

0 个答案:

没有答案