Hi i am new. i didn't understand howto insert data in a Datable from a database. Could someone provi
Hi i am new. i didn't understand howto insert data in a Datable from a database. Could someone provi
lupomeo
Posts: 6Questions: 2Answers: 0
Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:
Answers
There are many ways this can be done. A common way is to load the table data from the server using Ajax. See the Ajax docs for details. There are Ajax examples you can look at.
Its best to ask more specific questions and to provide basic information of your environment.
Kevin
Yes i have seen the examples but my problem is that when i use ajax with this code the data are succesfully inserted in the table BUT the table don't display the pages, display the wrong nuber of items, and lose the search input.
function view_data(){
$con = connection();
$query = "SELECT * FROM
tipologie
";$result = mysqli_query($con, $query);
}
If you are populating the HTML table data this way then don't use
ajax
. Read about the supported Data Sources. Looks like you will want to initialize using DOM sourced data. See this example.Kevin
Anyone else that can really help ?
I think Kevin's answer is spot on (as they always are).
Maybe we should take a step back - first of all: how do you want to populate the table's data? Via Ajax? If so, don't have the Ajax response return HTML for the table rows. Let DataTables do that for you! Reply to the Ajax request with JSON - e.g.:
Then:
Then you can populate your DataTable in the say way as this example.
See this section of the manual for more details on this.
Allan