Posted inTechnology

Jquery select2 ajax autocomplete example with demo in PHP codeigniter Example

Today, We want to share with you select2 codeigniter.In this post we will show you CodeIgniter Autocomplete Search from Database using AJAX Example, hear for Codeigniter 3 – select2 ajax autocomplete from database example with demo we will give you demo and example for implement.In this post, we will learn about
codeigniter autocomplete from database
with an example.

Loading data remotely in Select2 in CodeIgniter

application/views/welcome_message.php



  Jquery select2 ajax autocomplete example code with demo - www.pakainfo.com
  
  
  




Select Box with Search Option Jquery Select2.js

Create Route

application/config/routes.php

$route['default_controller'] = 'welcome';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;


$route['search'] = "search/index";

Create Controller

application/controllers/Search.php

defined('BASEPATH') OR exit('No direct script access allowed');

class Search extends CI_Controller {
	public function index()
	{
		$json = [];


		$this->load->database();

		
		if(!empty($this->input->get("q"))){
			$this->db->like('name', $this->input->get("q"));
			$query = $this->db->select('id,name as text')
						->limit(10)
						->get("products");
			$json = $query->result();
		}

		
		echo json_encode($json);
	}
}

I hope you get an idea about autocomplete textbox in jquery example using database in codeigniter.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

Your email address will not be published. Required fields are marked *

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype