here is my HTMl code actually i want to insert the input text data if only the checkbox is checked and there are 50+ input fields with unique data to insert like this HTML
<div class="row">
<form action="" method="post" name="country_form" class="form" role="form">
<div class="form-group">
<div class="col-lg-3 col-xs-12 bg-info">
<div class="squaredOne pull-left">
<input type="checkbox" value="" id="Asian" name="check[0]" />
<label for="Asian"></label>
</div>
<span class="pull-left">Asian</span><span class="clearfix"></span>
<input class="bg-alert" type="number" id="bales" name="Asian[0]" min="0" placeholder="Asian Bales">
</div>
<div class="col-lg-3 col-xs-12 bg-info">
<div class="squaredOne pull-left">
<input type="checkbox" value="" id="BabyGrow" name="check[1]" />
<label for="BabyGrow"></label>
</div>
<span class="pull-left">Baby Grow</span><span class="clearfix"></span>
<input class="bg-alert" type="number" id="bales" name="BabyGrow[1]" min="0" placeholder="Baby Grow Bales">
</div>
<div class="col-lg-3 col-xs-12 bg-info">
<div class="squaredOne pull-left">
<input type="checkbox" value="" id="Boys_Pants" name="check[2]" />
<label for="Boys_Pants"></label>
</div>
<span class="pull-left">Boys Pants</span><span class="clearfix"></span>
<input class="bg-alert" type="number" id="bales" name="Boys_Pants[2]" min="0" placeholder="Boys Pant Bales">
</div>
<div class="col-lg-3 col-xs-12 bg-info">
<div class="squaredOne pull-left">
<input type="checkbox" value="" id="Boys_Colour_Shirts" name="check[3]" />
<label for="Boys_Colour_Shirts"></label>
</div>
<span class="pull-left">Boys Colour Shirts</span><span class="clearfix"></span>
<input class="bg-alert" type="number" id="bales" name="Boys_Colour_Shirts[3]" min="0" placeholder="Boys Colour Shirt Bales">
</div>
<div class="form-group">
<input type="button" value="Next" class="btn-block btn btn-lg btn-info"/>
</div>
</form>
<div>
</div>
Also in my Database all the input fields are in separate column like this CT_ID | Asian | BabyGrow | Baby_Pants | Baby Colour Shirts e.t.c (60 more columns)
In checkbox field Check[0] and in Input text Asian[0] array is same is that correct? How can i do this
My PHP code idea to insert or update is:
for ($j = 0; $j < count($_POST['check']); $j++) {
if (!empty($_POST['check'][$j])) { /* CHECK IF CHECKBOX IS SELECTED */
$q = "INSERT INTO container (Asian, BabyGrow) VALUES ('$Asian','$BabyGrow')";
$q = mysql_query($q);
}
}
but i am not sure and also it's hard to write html for 50+ div boxes with unique input fields