Today, We want to share with you ajax live search table generation using codeigniter.In this post we will show you ajax pagination in codeigniter example demo, hear for dropdown search filter in codeigniter we will give you demo and example for implement.In this post, we will learn about Ajax Pagination with Search and Filter in CodeIgniter with an example.
ajax live search table generation using codeigniter
There are the Following The simple About search option in codeigniter Full Information With Example and source code.
As I will cover this Post with live Working example to develop search data from database in codeigniter using ajax, so the how to search and display data from database in codeigniter using ajax is used for this example is following below.
Live Data Search in Codeigniter using Ajax JQuery
The Simple jquery source code is given below
<script> $(document).ready(function(){ $("#search").keyup(function(){ var str= $("#search").val(); if(str == "") { $( "#txtHint" ).html("<b>Doctor information will be listed here...</b>"); }else { $.get( "<?php echo base_url();?>home/ajaxsearch?id="+str, function( data ){ $( "#txtHint" ).html( data ); }); } }); }); </script>
The complete HTML with jquery source code for input view is given below
<div class="container"> <!-- search box container starts --> <div class="search"> <div class="space"></div> <form action="" method="get"> <div class="row"> <div class="corona-virus col-lg-10 col-lg-offset-1"> <div class="dsp input-group jdk"> <span class="input-group-addon" >DOCTOR SEARCH</span> <input autocomplete="off" id="search" type="text" class="form-control input-lg" placeholder="Search Doctor name or Hospital " > </div> </div> </div> <div class="space"></div> </form> </div> <!-- search box container ends --> <div id="txtHint" style="padding-top:50px; text-align:center;" ><b>Doctor information will be listed here...</b> </div> </div> <script> // above some script source codes... </script>
And then the simple server side source code for output view
<?php if(!empty($doctortable )) { $output = ''; $outputdata = ''; $outputtail =''; $output .= '<div class="container"> <div class="table-responsive"> <table class="table table-bordered"> <thead> <tr> <th>Doctor No</th> <th>Doctor Name</th> <th>Hospital</th> <th>Charge</th> </tr> </thead> <tbody> '; foreach ($doctortable as $objects) { $outputdata .= ' <tr> <td >'.$objects->DOCTORID.'</td> <td >'.$objects->TITLE.'</td> <td>'.$objects->HOSPITAL.'</td> <td>'.$objects->CHARGE.'</td> </tr> '; // echo $outputdata; } $outputtail .= ' </tbody> </table> </div> </div> '; echo $output; echo $outputdata; echo $outputtail; } else { echo 'Any Data Not Found'; }
The home controller code is given below
public function ajaxsearch() { if(is_null($this->input->get('id'))) { $this->load->view('input'); } else { $this->load->model('Doctormodel'); $data['doctortable']=$this->Doctormodel->doctortable($this->input->get('id')); $this->load->view('output',$data); } }
The function source code for doctortable function in Doctormodel is given below
function doctortable($search){ $query = $this ->db ->select('*') ->from('doctor') ->like('TITLE',$search) ->or_like('HOSPITAL',$search) ->get(); if($query->num_rows()>0) { return $query->result(); } else { return null; } }
Web Programming Tutorials Example with Demo
Read :
Summary
You can also read about AngularJS, ASP.NET, VueJs, PHP.
I hope you get an idea about Live Search Using Jquery Ajax, Php Codeigniter and Mysql.
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.