Topic: Exemplo use database in datatables with sorting

Meireles pro asked 6 years ago


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

 

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

?>

<!--Table head-->
<thead>
<tr>
<th>
<input type="checkbox" id="checkbox">
<label for="checkbox" class="mr-2 label-table"></label>
</th>
<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>
</tr>
</thead>
<!--Table head-->

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

not work, not made pagination,

Witold Tkaczyk free commented 6 years ago

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

Meireles pro commented 6 years ago

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

Meireles pro commented 6 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.

FREE CONSULTATION

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

Status

Answered

Specification of the issue

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