CodeIgniter Laravel PHP Example Javascript jQuery MORE Videos New
Need a Website Or Web Application Contact : +91 9437911966 (Whatsapp) Note: Paid Service

How to insert Multiple Checkbox value in CodeIgniter framework MySQL

In this example we are going to show you how to how to insert Multiple Checkbox value in CodeIgniter framework MySQL PHP.

Here we using 3 files for insert Multiple Checkbox value in CodeIgniter framework MySQL PHP:

  • Crud.php Path: codeIgniter\application\controllers\Crud.php
  • Crud_model.php Path: codeIgniter\application\models\Crud_model.php
  • multicheck_insert.php Path: codeIgniter\application\views\multicheck_insert.php

Crud.php (Controller)

	class Crud extends CI_Controller 
		public function __construct()
			parent::__construct();/* call CodeIgniter's default Constructor */
			$this->load->database();/* load database libray manually */
			$this->load->model('Crud_model');/* load Model */
		public function multicheck()
				$user_id=1;/* Pass the userid here */
				$checkbox = $_POST['check']; 
					$category_id = $checkbox[$i];
					$this->Crud_model->multisave($user_id,$category_id);/* Call the modal */
				echo "Data added successfully!";

Crud_model.php (Model)

class Crud_model extends CI_Model 
	function multisave($user_id,$category)
		$query="insert into user_cat values($user_id,$category)";

insert.php (View)

<!DOCTYPE html>
<form method="post" action="">
	<input type="checkbox" id="checkItem" name="check[]" value="1">Car<br>
	<input type="checkbox" id="checkItem" name="check[]" value="2">Bike<br>
	<input type="checkbox" id="checkItem" name="check[]" value="3">Cycle<br>
	<button type="submit" class="btn btn-primary" style="width:200px" name="save">Submit</button>

Run the program on your browser with URL:


Here codeIgniter is my folder name. Put your folder name instead of codeIgniter.Rest of things are same.