Child Row data from Mysql
Child Row data from Mysql
simpleman
Posts: 6Questions: 2Answers: 1
Hi All,
I have searched this forum + google but not getting my head around this.
I want to use the rows functionality as shown here https://datatables.net/examples/api/row_details.html
But i need to be able to populate the rows with data from a mysql database query. I cant figure out how to do this.
Has any one got a working example of this please that I can follow and learn?
Thanks!
Regards,
R
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Its difficult to help without understanding more about your environment and your specific questions. The example is a good place to learn. Essentially you can copy the code and update the format function to display the additional fields you are interested in.
Assuming you have a working Datatables config you update the SQL query to include the additional you want to display in the child row. Change the format function, in the example, to display the desired fields. Add the CSS from the example and you should be all set.
If this doesn't help please post more info and questions.
Kevin
Hi Kevin,
Thanks for responding. The data is farily simple (like my name! ). I have a index.php which gets a json response from response.php which pulls data from mysql. So here is my code! When I try to run this the website is just stuck and does not load anything. What is that I am doing wrong? If there is an example of similar thing (i.e pulling data from MySQL it would be great!
Thanks in advance Kevin for your input (and any one else who is going to help me out here!)
Index.php
Response.php:
```
<?php > ``` ?><?php
//include connection file
include_once("connection.php");
I'm not familiar with PHP and not sure what the JSON response looks like. Does the mysqli_fetch_row function prefix the column names with "i"?
Can you provide the JSON response?
Do you get any errors in the browser's console?
Kevin
This is now sorted. For the rest of you if you want some info here is how it looks like