Sort PHP table [closed]

-2

I'm trying to sort a table that is in PhP and that pulls the data from the database, I tried with js called sorttable, but it did not work, the table is with that code:

            echo '<table class="sortable">'; 
            echo "<tr><th>Empresa</th><th>Atividade</th><th>Telefone</th><th>Licença</th><th>Contato</th><th>#</th></tr>";
            while ($row_empresas = mysqli_fetch_assoc($resultado_empresas)){
            echo '<tr>';
            echo '<td>' . $row_empresas['nomeCliente'] . '</td>';
            echo '<td>' . $row_empresas['documento'] . '</td>';
            echo '<td>' . $row_empresas['telefone'] . '</td>';
            echo '<td>' . $row_empresas['cidade'] . '</td>';
            echo '<td>' . $row_empresas['email'] . '</td>';
            echo '<td>';
                echo '<a href="'.base_url().'index.php/base2/visualizar/'.$row_empresas['idClientes'].'" style="margin-right: 1%" class="btn tip-top" title="Ver mais detalhes"><i class="icon-eye-open"></i></a>';
                echo '<a href="'.base_url().'index.php/base2/editar/'.$row_empresas['idClientes'].'" style="margin-right: 1%" class="btn btn-info tip-top" title="Editar Cliente"><i class="icon-pencil icon-white"></i></a>';
            echo '</td>';
            echo '</tr>';

            }
            echo '</table>';    

How could I arrange it so that it could be sorted?

    
asked by anonymous 14.03.2018 / 21:40

1 answer

2

I use this Sorttable , example:

<html>
    <head>
        <title>Sorttable</title>
        <!-- Importa o JS -->
        <script type="text/javascript" src="https://kryogenix.org/code/browser/sorttable/sorttable.js"></script></head><body><!--Ativaosorttablenatabela--><tableclass="sortable">
            <thead>
                <tr><th>Person</th><th>Monthly pay</th></tr>
            </thead>
            <tbody>
                <tr><td>Jan Molby</td><td>£12,000</td></tr>
                <tr><td>Steve Nicol</td><td>£8,500</td></tr>
                <tr><td>Steve McMahon</td><td>£9,200</td></tr>
                <tr><td>John Barnes</td><td>£15,300</td></tr>
            </tbody>
            <tfoot>
                <tr><td>TOTAL</td><td>£45,000</td></tr>
            </tfoot>
          </table>
    </body>

It's very simple to use, and the documentation has more advanced uses (do not order by column, keep icons visible, change icons, ...) and explanations

    
15.03.2018 / 00:01