嘿,我的代码中有一些问题,当我通过复选框存储数据时,它存储了数据,但是存在一点问题 这是我的完整代码:
<?php
include("config.php");
if(isset($_POST['save'])){
$contact_sms = $_POST['contact_sms'];
$check[] = $_POST['check'];
$firm_name = $_POST['firm_name'];
var_dump($_POST);
$checkbox = $_POST['check'];
for($i=0;$i<count($checkbox);$i++){
$bulksms="INSERT INTO bulk_sms (sent_sms,firmname_sms,contact_sms) VALUES('".$checkbox[$i]. "','".$firm_name[$i]. "','$contact_sms')";
$smsquery=mysqli_query($conn, $bulksms);
}
}
$sql="SELECT * FROM inventory_details where status ='0' AND role='0' ORDER BY position ASC, role ASC, visiter DESC limit 0,100";
$query=mysqli_query($conn, $sql);
?>
<form method="post" action="" id="msform">
<?php
$i=0;
while($row=mysqli_fetch_assoc($query)){
$id = $row['id'];
$firm_name = $row['firm_name'];
?>
<div class="col-md-4">
<input type="text" class="form-control" name="id_sms" value="<?php echo $id;?>">
</div>
<div class="col-md-6">
<input type="text" class="form-control" name="firm_name[]" value="<?php echo $firm_name;?>">
</div>
<div class="col-md-2">
<input type="checkbox" id="checkItem" name="check[]" value="<?php echo "$id"; ?>">
</div>
<?php
$i++;
}
?>
<input type="text" class="form-control" name="contact_sms" placeholder="Contact Number..">
<button type="submit" class="btn btn-success" name="save">Send</button>
</form>
当我标记任何复选框并提交时,复选框的id
正确地存储在sent_sms
字段中,但是firm_name
从头开始存储在firmname_sms
字段中,即在firmname_sms
字段中,未存储检查值。
foreach循环可能吗?如果是,请帮帮我......