Help! I can't use datatables

Help! I can't use datatables

novice232562novice232562 Posts: 1Questions: 1Answers: 0
edited January 2016 in Free community support

I am using sql to show the data in a table. The output is only the table but the datatable is cannot be seen.
```

$(document).ready(function() { $('#discharged').DataTable(); } );

<?php
$conn = new mysqli($hostname, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

$sql = "SELECT * FROM PICDetails WHERE Discharged= 'Yes'  ";

$result = $conn->query($sql);

if ($result->num_rows > 0) {
// output data of each row
echo "

"; while($row = $result->fetch_assoc()) { echo">" ; } echo "
Namephone numberReport NumberNationalityDischarged DateDischarged Time
".$row["Name"]."". $row["phone"]."". $row["ReportNum"]."". $row["Nationality"]."". $row["DDate"]."".$row["DTime"]."

";
} else {
echo "0 results";
}
$conn->close();

<?php > ``` ?>

Answers

  • allanallan Posts: 63,761Questions: 1Answers: 10,510 Site admin

    Per the forum rules, please link to a test case showing the issue.

    Also, move the tbody out of the while loop. DataTables only supports a single tbody.

    Allan

This discussion has been closed.