hey i have almost done with the checkbox values that has to be inserted in database but there is a little bit problem.
Here is my full code :
<?php
include("config.php");
if(isset($_POST['save'])){
$contact_sms = $_POST['contact_sms'];
$mobileno = $_POST['mobileno'];
$checkbox = $_POST['check'];
for($i=0;$i<count($checkbox);$i++){
$bulksms="INSERT INTO bulk_sms (sent_sms,contact_sms,mobileno) VALUES('".$checkbox[$i]. "', '$contact_sms', '$mobileno')";
$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">
<div class="container">
<div class="row invent_det cate_head">
<div class="col-md-2 "><strong>ID</strong></div>
<div class="col-md-6 "><strong>PRIMARY MOBILE NO.</strong></div>
<div class="col-md-4 "><strong><input type="checkbox" id="checkAl"> Select </strong></div>
</div>
<?php
$i=0;
$today_date=date("Y-m-d H:i:s", time());
while($row=mysqli_fetch_assoc($query)){
$id = $row['id'];
$firm_name = $row['firm_name'];
$PrimaryMobile_no = $row['PrimaryMobile_no'];
?>
<div class="row">
<div class="col-md-2 inventory-data">
<input type="text" class="form-control" name="id_sms" value="<?php echo $id;?>" disabled>
</div>
<div class="col-md-6 inventory-data">
<input type="text" class="form-control" name="mobileno[]" value="<?php echo $PrimaryMobile_no;?>" disabled>
</div>
<div class="col-md-4 inventory-data"><input type="checkbox" id="checkItem" name="check[]" value="<?php echo $row["firm_name"]; ?>-<?php echo $row["PrimaryMobile_no"]; ?>">
</div>
</div>
<?php
$i++;
}
?>
<div class="row">
<div class="inventory-data">
<input type="text" class="form-control" name="contact_sms" placeholder="Contact Number..">
</div>
<button type="submit" class="btn btn-success" name="save">Send</button>
</div>
</div>
</form>
<script>
$("#checkAl").click(function () {
$('input:checkbox').not(this).prop('checked', this.checked);
});
</script>
When i click on the "send" button, its stores the value of
<input type="checkbox" id="checkItem" name="check[]" value="<?php echo $row["firm_name"]; ?>-<?php echo $row["PrimaryMobile_no"]; ?>">
in the database inside "sent_sms" column and also i am storing the number inside "contact_sms" field.Till now, everything is working fine.
Now the problem is that, i am trying to store the value of
<input type="text" class="form-control" name="mobileno[]" value="<?php echo $PrimaryMobile_no;?>" disabled>
in the database inside "mobileno" column but failed to do so.
Please help me out, any hints or suggestions are most welcome. Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire