checkbox multiple select insert in php mysql Insert Value From CheckBox In Database mysql In PHP
PHP 0 Commentscheckbox multiple select insert in php mysql Insert Value From CheckBox In Database mysql In PHP
How do I insert multiple checkbox values into a table how to insert multiple checkbox id and value in a multiple column of mysql using php Insert multiple checkbox value in a single column and row of MySQL using PHP How to insert multiple checkbox into different column row in Mysql
<html> <head> <title> PHP Form<</title> </head> <body bgcolor="pink"> <h3>Insert Value From Checkboxes</h3> <form action="checkbox . php" method="post"> <input type="checkbox" name="chkl[ ]" value="Vineet Saini">topic 1<br /> <input type="checkbox" name="chkl[ ]" value="Ravi Sharma">topic 2<br /> <input type="checkbox" name="chkl[ ]" value="Rahul Dube">topic 3<br /> <input type="checkbox" name="chkl[ ]" value="Rajesh Verma">Rajesh Verma<br /> <input type="checkbox" name="chkl[ ]" value="Priyanka Sachan"> Priyanka Sachan<br /> <br> <input type="submit" name="Submit" value="Submit"> </form> </body> </html> <php include ("config . php"); $checkbox1 = $_POST['chkl'] ; if ($_POST["Submit" ]=="Submit") { for ($i=0; $i<sizeof ($checkbox1);$i++) { $query="INSERT INTO employee (name) VALUES ('".$checkboxl[$i]. "')"; mysql_query($query) or die(mysql_error()); } echo "Record is inserted"; } ?> insert multiple items with one query like this $query = "INSERT INTO example (orange) VALUES "; for ($i=0; $i<count($checkBox); $i++) $query .= "('" . $checkBox[$i] . "'),"; $query = rtrim($query,','); mysql_query($query) or die (mysql_error() ); implode and save values into one column <?php // Make a MySQL Connection mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("test") or die(mysql_error()); $checkBox = implode(',', $_POST['Days']); if(isset($_POST['submit'])) { $query="INSERT INTO example (orange) VALUES ('" . $checkBox . "')"; mysql_query($query) or die (mysql_error() ); echo "Complete"; } ?> onclick all select and insert in mysql php <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> $chk=""; foreach($_POST['check_list'] as $check) { // echo $check; //echoes the value set in the HTML form for each checked checkbox. //so, if I were to check 1, 3, and 5 it would echo value 1, value 3, value 5. //in your case, it would echo whatever $row['Report ID'] is equivalent to. // echo $check . ","; //$chk .= "'" . $check."', "; //echo $check_e; $chk .= $check . ","; //$value = $check; } $coursecatidcat = rtrim($chk,", "); echo $coursecatidcat; <div class="form-group"> <div class="form-group">Title</div><div class="form-group">Title</div> <!-- <label> Bank <input type="checkbox" name="vehicle" value="Bike"> </label> <label> SSC <input type="checkbox" name="vehicle" value="Bike"> </label>--> <script> $(document).ready(function () { $("#ckbCheckAll").click(function () { $(".checkBoxClass").prop('checked', $(this).prop('checked')); }); }); </script> Select <input type="checkbox" id="ckbCheckAll" /> , Bank <input type="checkbox" class="checkBoxClass" id="Checkbox1" value="1" name="check_list[]" /> SSC <input type="checkbox" class="checkBoxClass" id="Checkbox1" value="12" name="check_list[]" /> </div>