且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将选中的多个复选框中的值插入数据库

更新时间:2022-12-11 20:14:21

    <div class="panel-body">
     <label class="checkbox-inline"><input type="checkbox" name="price[]" value="Less than 10,000, "> Less than 10,000</label>
     <label class="checkbox-inline"><input type="checkbox" name="price[]" value="10,001 to 15000, "> 10,001 - 15000</label>
     <label class="checkbox-inline"><input type="checkbox" name="price[]" value="15,001 to 25000, "> 15,001 - 25000 </label>
     <label class="checkbox-inline"><input type="checkbox" name="price[]" value="25,001 to 35000, "> 25,001 - 35000 </label>
     <label class="checkbox-inline"><input type="checkbox" name="price[]" value="35,001 and more, "> 35,001 and more </label>
</div>
<?php
$price = $_REQUEST['price'];
//for single cell value separte by ,  
$p = implode(',',$price);
// for each value
for($i = 0;count($price)<$i;$i++){
    
    // put insert query and value of selected price
    $p = $price[$i];
}
?>