I found a tutorial to use datatables using the server side but it has a nested if for case cases (if the search entry is empty, if it is ordered by columns, etc) and I would like to place it within a single stored procedure
https://www.webslesson.info/2017/01/php-pdo-ajax-crud-with-data-tables-and-bootstrap-modals.html
$query = '';
$query .= "SELECT * FROM empleados ";
if(isset($_POST["search"]["value"])){
$query .= 'WHERE NombreEmpleado LIKE "%'.$_POST["search"]["value"].'%" ';
$query .= 'OR ApellidoPat LIKE "%'.$_POST["search"]["value"].'%" ';
$query .= 'OR Apellidomat LIKE "%'.$_POST["search"]["value"].'%" ';
}
if(isset($_POST["order"])){
$query .= 'ORDER BY '.$_POST['order']['0']['column'].' '.$_POST['order']['0']['dir'].' ';
} else {
$query .= 'ORDER BY IdEmpleado DESC ';
}
if($_POST["length"] != -1){
$query .= 'LIMIT ' . $_POST['start'] . ', ' . $_POST['length'];
}