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.