Help! I can't use datatables
Help! I can't use datatables
novice232562
Posts: 1Questions: 1Answers: 0
I am using sql to show the data in a table. The output is only the table but the datatable is cannot be seen.
```
<?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 "
Name | phone number | Report Number | Nationality | Discharged Date | Discharged Time |
---|---|---|---|---|---|
".$row["Name"]." | ". $row["phone"]." | ". $row["ReportNum"]." | ". $row["Nationality"]." | ". $row["DDate"]." | ".$row["DTime"]." |
";
} else {
echo "0 results";
}
$conn->close();
This discussion has been closed.
Answers
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 singletbody
.Allan