Topic: Exemplo use database in datatables with sorting

Meireles pro asked 5 years ago

i need example datatables sorting, for exemplo, find in my databse.


include "includes/config.php";
include "includes/sltpac.php";


<!--Table head-->
<input type="checkbox" id="checkbox">
<label for="checkbox" class="mr-2 label-table"></label>
<th class="th-lg"><a>Prontuário <i class="fa fa-sort ml-1"></i></a></th>
<th class="th-lg"><a href="">Nome<i class="fa fa-sort ml-1"></i></a></th>
<th class="th-lg"><a href="">Tipo paciente<i class="fa fa-sort ml-1"></i></a></th>
<th class="th-lg"><a href="">E-mail<i class="fa fa-sort ml-1"></i></a></th>
<th class="th-lg"><a href="">Telefone<i class="fa fa-sort ml-1"></i></a></th>
<!--Table head-->

<!--Table body-->
<?php foreach($dados as $cliente):?>
<th scope="row">
<input type="checkbox" id="checkbox1" value=<?=$cliente->id?>>
<label for="checkbox1" class="label-table"></label>
<td><?=$cliente->nome?> </td>
<td><?=$cliente->tipopaciente?> </td>
<td><?=$cliente->email?> </td>
<td><?=$cliente->telefone?> </td>
<?php endforeach; ?>
<!--Table body-->

not work, not made pagination,

Witold Tkaczyk free commented 5 years ago

Hi Meireles, Can you extend your question for $dados variable?

Meireles pro commented 5 years ago

Hi, dados is cursor(foreach), include select in database include "includes/sltpac.php";

Meireles pro commented 5 years ago

I want an example of "Table with pagination" with mysql connection.

Currently, we don't have any example of DataTables with MySQL and we're not planning to create it Anyway, I've found something that might be interesting to you. Please check this link Beware, that solution is a little bit old - Do not use mysql_* functions. They're deprecated and you should use PDO or mysqli instead

Please insert min. 20 characters.


Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.



Specification of the issue

  • User: Pro
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: No