Skip to main content

Create Live Search and Pagination in PHP with JQuery Datatable Plugin

Hi Guys today I am giving this tutorial for client side searching in a PHP with jQuery Datatable Plugin this is a very plain and smooth code so you can use it. you can use this code your website and projects where you want to use rapid searching you can use this code it is 5 line of code to create a plain and rapid searching so check it in below.

First of all you should add .CSS file and .JS file and Jquery file in your php file.

CDN CSS file
........................
http://cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css


CDN Jquery file
........................
https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js


CDN JS file
........................
http://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js




Example here :



<?php

$obj=new mysqli("localhost","root","","database_name");

?>

<html>
<head>

<title>Demo Live search and pagination</title>

<link rel="stylsheet" type="text/css" href="http://cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="http://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>

        </head>

<body>

<table id="tableId" class="display" cellspacing="1" width="100%">
        <thead>
            <tr>
                <th>Name</th>
                <th>Position</th>
                <th>Office</th>
                <th>Age</th>
                <th>Start date</th>
                <th>Salary</th>
            </tr>
        </thead>
        <tfoot>
            <tr>
                <th>Name</th>
                <th>Position</th>
                <th>Office</th>
                <th>Age</th>
                <th>Start date</th>
                <th>Salary</th>
            </tr>
        </tfoot>
        <tbody>
<?php
$sl="select * from table";
$qq=$obj->query($sl);
while($ff=$qq->fetch_object())
{
?>
            <tr>
                <td><?php echo $ff->name; ?></td>
                <td><?php echo $ff->position; ?></td>
                <td><?php echo $ff->office; ?></td>
                <td><?php echo $ff->age; ?></td>
                <td><?php echo $ff->srt_date; ?></td>
                <td><?php echo $ff->salary; ?></td>
            </tr>
<?php
}
?>
        </tbody>
    </table>

</body>
</html>

<script>
$(document).ready(function(){
    $('#tableId').DataTable();
});
</script>





Comments

Popular posts from this blog

GENERATE PDF FILE USING PHP DYNAMIC DATA FROM MYSQL DATABASE

In this post I will explain you how to generate a simple PDF file from your MySQL  database using PHP. For this thing we will use the   PHP  library FPDF which will allow us to generate the PDF file with the content and ourput format we want. Step-1: Get the data from MySQL database into the page Step-1: Download the FPDF library from  fpdf.org Step-2: Copy the  fpdf.php  file into your application folder Step-3: Use the fpdf library Download Code Here… http://ahir.16mb.com/email.php

Add Subscriber Example Using MailChimp API and PHP

MailChimp is an email marketing service, It is manage the subscribers of your website. MailChimp provides an easy way to integrate email signup form in your website and send the email newsletter to the subscribers. Beside the premium plan MailChimp also has a forever free plan. Using the free plan, you can add up to 2,000 subscribers to MailChimp and send 12,000 emails per month to the subscriber. In this tutorial, i will show you how to integrate newsletter subscription form in your website and add subscriber to list with MailChimp using PHP. We’ll use MailChimp API 3.0 and PHP to add subscriber to list without confirmation email. To integrate  MailChimp API in PHP  you need a MailChimp  API Key  and  List I D  where you want to add members. Before you begin, sign up for a MailChimp account and follow the below steps to get API Key and List ID. Creating API Key and List ID Get API Key: Login to your MailChimp account. Under the user menu drop...

How to read Excel file & Insert data in MySQL Database Through PHP

Today I am going to give you this tutorial on how to read excel file and insert data into MySQL Datbase using  PHP . I have used a php library  php-excel-reader  it is a very simple and easy to understand library to get excel data in your MySQL DB. You can print data in same excel format in HTML and display on browser. Download Code Here.....