datatable can't working with me !!
datatable can't working with me !!
i have this code please tell me what is my problem for the datatable doesn't work !
<?php
include 'conn.php';
$Chaines = array();
$rs = odbc_exec($conn,$sqlAllChaines);
while (odbc_fetch_row($rs))
{
$IdChaine=odbc_result($rs,1);
$Chaines[$IdChaine] = odbc_result($rs,2);
}
global $IdChaine, $NomChaine,$Chaines;
?>
<html>
<head>
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
<script>
$(document).ready( function () {
$('#tab').DataTable();
} );
</script>
</head>
<body>
<table class="display" id="tab" border="1" >
<th>Id Chaine</th>
<th>Nom Chaine</th>
<?php
foreach ($Chaines as $IdChaine => $NomChaine){ ?>
<tr>
<td align="center">
<?php print_r($IdChaine)?> </td>
<td align="center">
<?php print_r($NomChaine)?> </td>
<?php } ?>
</tr>
<th>Id Chaine</th>
<th>Nom Chaine</th>
</table>
</body>
</html>
AND THANKS
This question has an accepted answers - jump to answer
Answers
You are not creating a valid HTML table.
I don't know if that's your only problem, but it's a good place to start.
hummm so how i create it ???
You can have a look at http://live.datatables.net/ and make a live example. It will be way easier for you and us to help
With the php tags it is rather hard for us to see what is going on
Note that DataTables requires
thead
andtbody
elements.You can validate your HTML using the W3C validator. DataTables fundamentally assumes that your HTML for the table is valid.
Allan