你好每一个我都难以从我的插入代码中找到我的复选框值
HTML
<div class="form-group">
<label class="col-md-4 control-label">You are in :</label>
<div class="col-md-4">
<input name="lgan[]" type="checkbox" value="Hr-high"><label>Hr(High)</label><br>
<input name="lgan[]" type="checkbox" value="Pr-high"><label>Pr(High)</label><br>
<input name="lgan[]" type="checkbox" value="Fr-high"><label>Fr(High)</label><br>
<input name="lgan[]" type="checkbox" value="secretary-high"><label>secretary(High)</label><br>
<input name="lgan[]" type="checkbox" value="media-high"><label>media(High)</label><br>
</br>
<input name="lgan[]" type="checkbox" value="gwala-high" > <label>جوالة الخير(High)</label><br>
<input name="lgan[]" type="checkbox" value="mogtm3ia-high" > <label>الخدمة المجتمعية(High)</label><br>
<button type="submit" name="log" class="btn btn-warning" >Send <span class="glyphicon glyphicon-send"></span></button>
</div>
</div>
我的php代码是
<?php
if(isset($_POST["log"])){
$formok=TRUE;
$new_id = mysqli_insert_id($link);
if (!empty ($_POST['lgan'])){
foreach ($_POST['lgan'] as $value){
$res1 = mysqli_query($link,"INSERT INTO `lgan`(`ID1`,`lgan`)
VALUES ('$new_id','$value')");
echo mysqli_error($link); }}}
?>
this is my phpmyadmin database ID1 is an forign key from another table
我尝试使用此代码来检索数据但我的页面中没有任何内容
<?php
ini_set('display_errors', 1); ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
include ("../../../connection.php");
if(!empty($_SESSION["username"]) and $_SESSION["id"] !=""){
}else{
header('location:login.php');
}
$select1 = "select lgan from lgan where ID1='".$_GET["id"]."'";
$results1 = mysqli_query($link,$select1);
$row = mysqli_fetch_array($results1);
print_r ($row);
?>
<br> <input name="lgan[]" type="checkbox" value="Hr-high"
<?php if (in_array("Hr-high",$row)) { echo " checked"; }?> ><label>Hr(High)
</label><br>
<input name="lgan[]" type="checkbox" value="Pr-high" <?php
if (in_array("Pr-high",$row)) { echo " checked"; }?> ><label>Pr(High)
</label><br>
<input name="lgan[]" type="checkbox" value="Fr-high" <?php
if (in_array("Fr-high",$row)) { echo " checked"; }?> ><label>Fr(High)
</label><br>
<?php
?>
它会调查3个复选框! 我该怎么办?