when i store services and activity then services and activity value store multiple times in database, i also use implode instead of foreach but that time first service and first activity stored,the following image describe idea about what i exactly want
<form method='post' id='userform' action='savecheckbox.php'> <tr>
<td>Trouble Type</td>
<br>
<td>
<input type='checkbox' name='servicevar[]' value='1'>tds<br> <br>
<input type='checkbox' name='activityvar[]' value='1'>Return<br>
<input type='checkbox' name='activityvar[]' value='2'>Filling<br>
<br>
<input type='checkbox' name='servicevar[]' value='2'>Gst<br> <br>
<td>
<input type='checkbox' name='activityvar[]' value='1'>Return<br>
<input type='checkbox' name='activityvar[]' value='2'>Filling<br>
<br>
<input type='checkbox' name='servicevar[]' value='3'>vat<br> <br>
<td>
<input type='checkbox' name='activityvar[]' value='1'>Return<br>
<input type='checkbox' name='activityvar[]' value='2'>Filling<br>
<br>
</td> </tr> </table> <input type='submit' name="submit" class='buttons'>
<?php
if(isset($_POST['submit']))
{
$activity = $_POST['activityvar'];
$service = $_POST['servicevar'];
foreach ($service as $key => $servicevalue) {
foreach($activity as $key=>$activityvalue)
{
$query = "insert into serviceacitivitymap(service_id,activity_id)values('$servicevalue','$activityvalue')";
$insert_row=$conn->query($query) or die ($conn->error.__LINE__);
}
}
}
?>
Aucun commentaire:
Enregistrer un commentaire