0

I'm beginer to web development and I find on net something really usefull jquery datatables but now I have a problem becouse I know just javascript and jquery, so I have a problem How to connect datatable to mysql and how to send request and recieve response from server.

Here is the demo: https://editor.datatables.net/release/DataTables/extras/Editor/examples/bootstrap.html

So how I can connect this code example with my mysql dataBase?

Is there any tutorial step by step or something like that?

I need to do request and response ... I see in example file dataTables.php but this file is not in documentation...

3
  • I need some example with basic CRUD function and how to connect dataTable with mysql database... Commented Jan 22, 2014 at 16:14
  • did you look at this? datatables.net/release-datatables/examples/data_sources/… Commented Jan 22, 2014 at 16:30
  • no, i want to my example connect to mysql database Commented Jan 22, 2014 at 16:32

1 Answer 1

1

The best way to do this is using ajax.

You can request the items using datatables and fill the table with a json response.

Here's an example

                  $('#yourTable').dataTable(
                    {

                        "bDestroy" : true,
                        "iDisplayLength" : 20,
                        "sAjaxDataProp" : "",
                        "bPaginate": false,
                        "bInfo": false,
                        "sAjaxSource" : "foo.php (Json to fill the table)"
                        "aoColumns" : [ {
                            "mData" : "person.age"
                        }, {
                            "mData" : "person.name"
                        }, 
                           {
                            "mData" : "person.id",
                        }, 
                           {
                            "mData" : "time",
                        }]
                    });

mData are basically your table columns, and datatables will fill each of those mData colums with the json you designated.

You can read documentation on how mData works here:

http://datatables.net/usage/columns > Scroll to mData

Here is an example on how to get the mysql data from php for datatables.

http://datatables.net/examples/data_sources/server_side.html

For a basic implementation you just need the queries.

Hope it helps!

Sign up to request clarification or add additional context in comments.

6 Comments

yes but I want to get data from mysql database and not to send request on every search... just to send request on read, add, delete ... o this example on every search I send request... this is not really usefull
ok, I just want to catch full table and do the basic CRUD (create , read, update, delete) functions
Alright, you basically want to be able to do all the basic CRUD functions from the datatable?
yes, just crud function and search function to not call database
I try to use this plugin: editor.datatables.net/purchase but this plugin cost 70 euros ... so I dont want to pay them for basic crud functions...
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.