CodeIgniter Autocomplete Multiple input textbox with Database

CodeIgniter Autocomplete Multiple input textbox with Database

In this Post We Will Explain About is CodeIgniter Autocomplete Multiple input textbox with Database With Example and Demo.

Welcome on Pakainfo.com – Examples ,The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Jquery select2 ajax autocomplete example with demo in PHP

In this post we will show you Best way to implement Autocomplete Select2 Codeigniter bootstrap Metro UI 3.0, hear for How to php – Select2 load data from database – CodeIgnite with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Phase 1: Make Table

here show step by step to “CODEIGNITER 3 – SELECT2 jQuery AUTOCOMPLETE FROM DATABASE EXAMPLE WITH DEMO”.
In first of all created database and one created table we must have one table with some fake dummy records with this table structures.
-id
-name
-crated_at
-updated_at

Phase 2: Make View File

application/views/welcome_message.php



  Jquery select2 ajax autocomplete  Devloped By Pakainfo.com
  
  
  
  
  
  
  



Simple Select Box with Search Option Jquery Select2.js

$('.productName').select2({ placeholder: '--- Select Products ---', ajax: { url: '/search', dataType: 'json', delay: 250, processResults: function (data) { return { results: data }; }, cache: true } });

Phase 3: Create Route using CI_Controller

application/config/routes.php

In this Phase you need to add one create route for ajax search data all the products list. so open first of all routes.php file and simple put or add source code like as bellow:

$route['default_controller'] = 'welcome';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
$route['search'] = "search/index";

Phase 4: Create Controller

application/controllers/Search.php

and then, create simple new Search.php file in simple CI controllers folder and here easy put bellow code:

defined('BASEPATH') OR exit('No direct script access allowed');
class Search extends CI_Controller {
	public function index()

	{
		$result = [];
		$this->load->database();
		if(!empty($this->input->get("q"))){

			$this->db->like('name', $this->input->get("q"));

			$sql_query = $this->db->select('id,name as text')

						->limit(10)

						->get("tags");

			$result = $sql_query->result();

		}
		echo json_encode($result);
	}

}

Now, Good Luck we are simple autocomplete textbox ready to check, so we can check your own.

Example

I hope you have Got jQuery UI Autocomplete in CodeIgniter with Database And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.

Leave a Comment