PHP
<form action="page5_form.php" method="post" name= "test">
<ul>
<li>
<input name='arr[<?php echo $i?>][service]' type='checkbox' data-id='Incometax'value="<?php echo $service['service_id']?>"/><?php echo $service['servicename']?>
<ol>
<li>
<?php foreach ($activities as $activity) : ?>
<input type='checkbox' name='arr[<?php echo $i?>][activity][]' value="<?php echo $activity['id']?>" /><?php echo $activity['nameofactivity'];?>
</li>
<li>
<?php foreach ($pers as $per) : ?>
<input type='checkbox' name='arr[<?php echo $i?>][timeperiod][]' value="<?php echo $per['periodicity_id'];?>" /><?php echo $per['per_time'];?>
</li>
<br>
<?php endforeach;?>
<br>
<?php endforeach;?>
<br>
</ol>
</li>
</ul>
<?php
$i++;
endforeach;?>
<input name="number" type="hidden" value="<?php echo $next; ?>">
<input type="submit" name="submit" value="Submit"/>
</form>
Output of my php code is :-
- GST
- Return
- Monthly
- Yearly
- Revised
- Monthly
- Yearly
- Quartly
- Return
- Incomtax
- Application
- Monthly
- yearly
- Return
- Monthly
- Yearly
- Application
In this output
- Incometax and Gst are services.
- Return,revised are the activities of service 1 GST and application,Return are the activities of service 2 Incometax.
- Monthly,yearly,quartely are the period time of activity.
When I stored this services,My code for storage is
foreach($_POST['arr'] as $input)
{
$service = $input['service'];
echo $service;
echo "<br>";
foreach($input['activity'] as $act)
{
$query2 = "insert into serviceactmap(client_id,service_id,activity_id)values('$firmid','$servicevalue','$activityvalue')";
foreach($input['timeperiod'] as $per)
{
$query3 = "insert into mapactivityperodicity(client_id,activity_id,perodicity_id)values('$firmid','$activityvalue','$period')";
}
}
}
- I store services and activity in Serviceactivitymap table and activity and periodicity in activitypermap table
- When I store in activitypermap table, when I check 1st activity and 1,2 periodicity and 2nd activity and 1 periodicity then it store in db like 1st activity in activity id but 1,2,2 periodicity in per_id.
- When I select periodicity in any activity then all the values of periodicity repeated for all activity
Thank u
Aucun commentaire:
Enregistrer un commentaire