I have 2 checkboxes fields grabbing data from table. I would like to insert both of them in table. i success when i insert one of them but when i try to insert both of them i fail.
My form:
<form action="select_role_insert.php" method="post" >
<label>Supervisor</label>
<?php
$reqm = "SELECT manager_name FROM manager_name ";
$repm = mysqli_query($dbc, $reqm);
while ($rowm = mysqli_fetch_array($repm))
{
$manager_name= $rowm['manager_name'];
?>
<input type="checkbox" name="Supervisor[]"
value="<?php echo $manager_name?>" /> <?php echo $manager_name?><hr/>
<?php
}
?>
<label>Speciality</label>
<?php
$req = "SELECT name FROM claims_follow_up.user_speciality";
$rep = mysqli_query($dbc, $req);
while ($row = mysqli_fetch_array($rep)) {
$name = $row['name'];
?>
<input type="checkbox" name="Speciality[]"
value="<?php echo $name?>" /> <?php echo $name ?><hr/>
<?php}?>
select_role_insert.php - code that insert only one variable
$Speciality = $_POST['Speciality'];
foreach($Speciality as $i => $Speciality)
{
$carGroups = mysqli_query($dbc,"INSERT INTO
client_services SET Speciality ='$Speciality '");
}
Please help me to insert both supervisor and speciality variables.. Thanks in advance