Data Tables + PHP

Data Tables + PHP

brightsonbrightson Posts: 5Questions: 0Answers: 0
edited March 2009 in General
Hi

I am new to this forum. Can anyone explain how to get the data from data tables to a php script. Please explain with a simple example.

Regards,
Brightson

Replies

  • Jay CJay C Posts: 2Questions: 0Answers: 0
    Question, when you say "data tables" do you mean database tables or do you mean dataTables-1.4 the plug-in :)

    if the former, then you will need to create a php file that first queries your database (is it safe to assume you already know how to do this?). The trick is making the output match the aaData format dataTables plug-in is looking for. Have a look at the jason_source.txt file in the media/examples_support sub-directory of the distribution zip.

    { "aaData": [
    [ "Trident", "Internet Explorer 4.0", "Win 95+", 4, "X" ],
    [ "Webkit", "Safari 3.0", "OSX.4+", 522.1, "A" ]
    ] }

    Note that each table element is in quotes and the comma separate rows are in brackets.

    Does this help?

    Jay
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi Brightson,

    Like Jay I'm a little bit confused with what you are actually trying to achieve here. Are you looking to get your data into DataTables, or out of DataTables?

    If you want to create a DataTable using data from PHP the easiest way is to output it as a table and then simply create the DataTable as shown in here: http://www.datatables.net/examples/example_zero_config.html

    If you want to create a DataTable using data from PHP via Ajax then you can use the sAjaxSource initialisation parameter as shown here: http://www.datatables.net/examples/example_ajax_source.html

    If you want to get the data from DataTables, you'll need to be a bit more specific about what you actually want to achieve. What data do you want to get from it? Form data?

    Allan
  • brightsonbrightson Posts: 5Questions: 0Answers: 0
    Thanks Jay and allan
    Actually I was referring to data from dataTables-1.4 and your reply explained both. Thanks a lot.
This discussion has been closed.