jeudi 30 août 2018

Store services and activity with periodicity related in each other

HTML

<form method='post' id='userform' action='arrayvalue.php'>



       <input type='checkbox' name='servicevar[]' value='Gst'>Gst<br> <br>


        <input type='checkbox' name='activityvar[]' value='Return'>Return<br>
         <input type='checkbox' name='pervar[]' value='Monthly'>Monthly<br>
         <input type='checkbox' name='pervar[]' value='Yearly'>Yearly<br>



        <input type='checkbox' name='activityvar[]' value='Filling'>Filling<br>
          <input type='checkbox' name='pervar[]'value='Monthly'>Monthly<br>
          <input type='checkbox' name='pervar[]' value='Yearly'>Yearly<br>
        <br>




        <input type='checkbox' name='arr[2][service]' value='Incometax'>Incometax<br> <br>


        <input type='checkbox' name='arr[2][activity][]' value='Return'>Return<br>
         <input type='checkbox' name='arr[2][per][]' value='Monthly'>Monthly<br>
         <input type='checkbox' name='arr[2][per][]' value='Yearly'>Yearly<br>



        <input type='checkbox' name='activityvar[]' value='Filling'>Filling<br>
          <input type='checkbox' name='pervar[]'value='Monthly'>Monthly<br>
          <input type='checkbox' name='pervar[]' value='Yearly'>Yearly<br>



        <input type='checkbox' name='activityvar[]' value='Return'>Revised<br>
         <input type='checkbox' name='pervar[]' value='Monthly'>Monthly<br>
         <input type='checkbox' name='pervar[]' value='Yearly'>Yearly<br>
        <br>

   <input type='submit' name="submit" class='buttons'>
</form>

The output of this code is:-

  • Gst
    • Return
      • Monthly
      • Yearly
    • Filling
      • Monthly
      • Yearly
  • Incometax
    • Return
      • Monthly
      • Yearly
    • Filling
      • Monthly
      • Yearly
    • Revised
      • Monthly
      • Yearly

I store all this values in mapping table,

I have serviceactivitymap Table where I store service with related activity,

I have activitypermap Table where I store activity related to periodicity.

     foreach ($_POST['arr'] as $input) {


            $servicevalue = $input['service'];
                $query2 = mysql_query("insert into mapclientservice(client_id,service_id)values('$firmid','$servicevalue')",$connection);



          foreach ($input['activity'] as $activity) {

            $servicevalue = $input['service'];

             $query3 = mysql_query("insert into mapserviceactivity(service_id,activity_id)values('$servicess','$activity')",$connection);


             foreach ($input['timeperiod'] as $period) {

                $query4 = mysql_query("insert into mapactivityperodicity(activity_id,perodicity_id)values('$activity','$period')",$connection);

             }

        }

    }

This is used for store services activity and periodicity. But when I store activity and periodicity then there is problem,value of periodicity not store correct.

All the checked periodicity stored with all activity, How to store it with proper activity with periodicity




Aucun commentaire:

Enregistrer un commentaire