How can i show Select statement results in the Data-table in PHP. I have used the following code to display record from Mysql table but not working.
I have tried this but no luck
Select Statement
$sql = "SELECT demand.itemid,demand.qty, MIITEM.descr,MIITEM.descr,supplier.suplId,supplier.suplProdCode,supplier.itemId,MIILOC.qStk,MIILOC.qWIP,MIILOC.qRes, MIILOC.qOrd
FROM MIITEM
LEFT JOIN demand
ON MIITEM.itemId=demand.itemId
LEFT OUTER JOIN supplier
ON MIITEM.itemId = supplier.itemId
LEFT OUTER JOIN MIILOC
ON MIITEM.itemId = MIILOC.itemId
WHERE MIITEM.itemId=demand.itemId AND supplier.itemId=demand.itemId";
$result = $conn->query($sql);
Displaying Records
echo"<table id='example' class='display' cellspacing='0' width='100%'>
<thead>
<tr style='background:#ccc;'>
<th STYLE='WIDTH:50px; padding:7px'>ID</th>
<th STYLE='WIDTH:250px; padding:7px'>Description</th>
<th STYLE='WIDTH:100px; padding:7px'>Supplier#</th>
<th STYLE='WIDTH:200px; padding:7px'>Supplier </th>
<th STYLE='WIDTH:100px; padding:7px'>ON WO</th>
<th STYLE='WIDTH:100px; padding:7px'>Stock</th>
<th STYLE='WIDTH:100px; padding:7px'>WIP</th>
<th STYLE='WIDTH:100px; padding:7px'>Reserve</th>
<th STYLE='WIDTH:100px; padding:7px'>On Order</th>
</tr> </thead></table>";
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo"<table id='example' class='display' cellspacing='0' width='100%'><tbody>
<tr>
<th STYLE='WIDTH:50px; padding:7px'>"; echo$row["itemid"];echo"</th>
<th STYLE='WIDTH:250px; padding:7px'>"; echo$row["descr"];echo"</th>
<th STYLE='WIDTH:100px; padding:7px'>"; echo$row["suplId"];echo"</th>
<th STYLE='WIDTH:200px; padding:7px'>"; echo$row["suplProdCode"];echo" </th>";
echo"<th STYLE='WIDTH:100px; padding:7px'>";echo$row["qty"];echo"</th>";
echo"<th STYLE='WIDTH:100px; padding:7px'>";echo$row["qStk"];echo"</th>";
echo"<th STYLE='WIDTH:100px; padding:7px'>";echo$row["qWIP"];echo"</th>";
echo"<th STYLE='WIDTH:100px; padding:7px'>";echo$row["qRes"];echo"</th>";
echo"<th STYLE='WIDTH:100px; padding:7px'>";echo$row["qOrd"];echo"</th>";
echo"</tr></tbody></table>";
Here is the Javascript code and the CSS file from CDN but nothing is changing.
<script type="text/javascript" src="//code.jquery.com/jquery-1.12.3.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/select/1.2.0/js/dataTables.select.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#example').DataTable( {
select: true
} );
} );
</script>