How to use DataTables in Bootstrap

DataTables in Bootstrap

If you are looking for on how to use DataTables in Bootstrap then you are at the right place. In this article, we are going to tackle about on how to use data tables in bootstrap. This is a use of the jQuery plugin to have dynamic tables which can provide Searching, Sorting, data in every page. Also, it has a pagination to controls the pages. You can use it for your future projects or you can share this tutorial with your friends to know also on how to use data tables in bootstrap. You can also check the live demo of this simple tutorial, so you can get an idea and you can try this out, let's start coding.

Creating Our Table

  1.    <div class="container">
  2.    <table id="example"></table>
  3.    </div>

Creating Script For Our Data

  1. <script type="text/javascript" src="datatables.min.js"></script>
  2. <script type="text/javascript" charset="utf-8">
  3. $(document).ready(function()
  4. {
  5.         $('#example').dataTable( {
  6.         "aaData": [
  7.                         ["PHP Connection To MySQL","https://www.sourcecodester.com/tutorials/php/10306/php-connection-mysql.html"],
  8.                         ["PHP MySQL Database","https://www.sourcecodester.com/tutorials/php/10307/php-mysql-database.html"],
  9.                         ["PHP Creating MySQL Tables","https://www.sourcecodester.com/tutorials/php/10308/php-creating-mysql-tables.html"],
  10.                         ["PHP Inserting Data To MySQL","https://www.sourcecodester.com/tutorials/php/10310/php-inserting-data-mysql.html"],
  11.                         ["PHP Select Data In MySQL","https://www.sourcecodester.com/tutorials/php/10311/php-select-data-mysql.html"],
  12.                         ["PHP Deleting Data In MySQL","https://www.sourcecodester.com/tutorials/php/10312/php-deleting-data-mysql.html"],
  13.                         ["PHP Update Data In MySQL","https://www.sourcecodester.com/tutorials/php/10316/php-update-data-mysql.html"],
  14.                         ["PHP Get ID Of Last Inserted Data In MySQL","https://www.sourcecodester.com/tutorials/php/10318/php-get-id-last-inserted-data-mysql.html"],
  15.                         ["PHP Insert Multiple Data In MySQL","https://www.sourcecodester.com/tutorials/10319/php-insert-multiple-data-mysql.html"],
  16.                         ["Add, Edit, Delete with data table using PDO in PHP/MySQL","https://www.sourcecodester.com/tutorials/php/10320/add-edit-delete-data-table-using-pdo-phpmysql.html"],
  17.                         ["Free Source Code","https://www.sourcecodester.com/"]
  18.                         ],
  19.         "columns": [
  20.             { "title": "<b style='color:blue;'>Title of the Tutorial</b>" },
  21.             { "title": "<b style='color:blue;'>Tutorial Link</b>" }
  22.         ]
  23.     });  
  24. });
  25. </script>

Design Of Our Table

  1. <script type="text/javascript">
  2.          $('#example')
  3.         .addClass('table table-bordered table-striped');
  4. </script>

Output:

List of data in data tables. Result If the user searching in data tables. Result Hope you like this tutorial. Kindly share with your friends. Just click the "Download Code" to have a full source code on how to use data tables in bootstrap. If you are interested in programming, we have an example of programs that may help you even just in small ways. Share us your thoughts and comments below. Thank you so much for dropping by and reading this tutorial post. For more updates, don’t hesitate and feel free to visit this website more often and please share this with your friends or email me at [email protected]. Practice Coding. Thank you very much.

Add new comment