How can I display datatable rows based on a condition with data sourced from mysql using php
How can I display datatable rows based on a condition with data sourced from mysql using php
jiawenchin
Posts: 1Questions: 1Answers: 0
Description of problem:
Like how mysql shows its rows based on a WHERE clause, I would like to know if there is a way to show specific data rows sourced from mysql. If this question has been asked previously, apologies and pointers to the discussion by giving me the link would be very much appreciated.
These are my code relevant to creating the datatable:
The HTML:
<div class="viewVacBatch2TableContainer table-responsive">
<table class="table table-bordered" id="viewVacBatch2DataTable">
<thead class="table-dark">
<tr>
<th>Appointment Date</th>
<th>Status</th>
<th style="width: 33%;">Selection</th>
</tr>
</thead>
<tbody id="viewVacBatch2TableBody">
</tbody>
</table>
</div>
The Javascript:
$(document).ready(function () {
var table = $('#viewVacBatch2DataTable').DataTable
({
"processing" : true,
"serverSide" : true,
"ajax": "server_side/server_processing.php",
"responsive": true,
"sPaginationType": "full_numbers",
"columnDefs": [{ "targets": -1, "data": null, "defaultContent": "<button type='button' class='btn btn-outline-secondary btn-squared tableButton' data-bs-target='#viewVacBatch2Modal' id = 'btnDetails' data-bs-toggle='modal'>s e l e c t</button>"}]
});
});
The files used : server_processing.php and ssp.class.php are attached,
Thanks in advance
Answers
I'm finding this
https://datatables.net/blog/2020-05-12#Writing-a-Controller
easier to use than the ssp.class.php, which is only a starting point and needs significant amendment to be fully functional.