Hy, I want to insert different data to the same column in the database. let see the Picture first. if the user can check
the New Product?
checkbox. then I want this can be stored in the product_label
column of the database with a value of new
. Now if someone clicks the Product on Sale?
checkbox then I want to send the value sale
to the database column product_label
. and if the user cannot be checked the both of the checkboxes then I want to send null
to the product_label
column of the database.
Now here is the HTML code for that. I just show only the checkboxes from the HTML code because the rest of the code is too lengthy.
<div class="col-md-4">
<div class="form-group">
<label for="Sale">New Product?</label>
<input type="checkbox" id="new_product" name="new_product" class="checkbox checkboxsize">
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="Sale">Product On Sale?</label>
<input type="checkbox" id="sale" name="sale" class="checkbox checkboxsize">
</div>
</div>
and this is PHP code for insertion.
$new_product = $_POST['new_product'];
$label = $_POST['sale'];
if($label==true)
{
$label="sale";
}
else if($new_product==true){
$new_product ="new";
}
else{
}
$query = "INSERT INTO `products`(`product_title`, `product_img1`, `product_img2`, `product_img3`, `product_price`, `product_desc`, `product_keywords`,`product_size`, `product_color`,`product_label`) VALUES ('$product_category','$category','$title','$path1','$path2','$path3','$price','$description','$keywords','$product_size','$product_color','$label')";
Now here I am stuck with this code. I didn't know how to get and insert these value to the same column product_label