terça-feira, 29 de outubro de 2019

usersListar.php

<?php
#usersListar.php
require_once("restrict.php");
$table="v1_users";
$sql="SELECT * FROM $table";
require_once("connection.php");
$query=mysqli_query($connect,$sql) or die("Erro na query SELECT * FROM $table");
$total=mysqli_num_rows($query);
if($total>0){
    $fetch=mysqli_fetch_assoc($query);
}
?>
    <!DOCTYPE html>
    <html lang="pt">

    <head>
        <meta charset="UTF-8">
        <title>Listagem de utilizadores</title>
    </head>

    <body>

        <?php if($total>0){ ?>
            <h1>Foram encontrados <?php echo $total;?> registos.</h1>
            <table>
                <tr>
                    <th>#</th>
                    <th>Username</th>
                    <th>Privilegio</th>
                    <th>Estado</th>
                    <th>Editar</th>
                </tr>
                <tr>
                    <td colspan="5">
                        <hr>
                    </td>
                </tr>
                <?php $i=0; do { $i++;?>
                    <tr>
                        <td>
                            <?php echo $i;?>
                        </td>
                        <td>
                            <?php echo $fetch['username'];?>
                        </td>
                        <td>
                            <?php echo $fetch['privilegio'];?>
                        </td>
                        <td>
                            <?php
if($fetch['estado']==1){
    echo "Ativo";
}
                                ;?>
                        </td>
                        <td>Editar</td>
                    </tr>
                    <?php } while($fetch=mysqli_fetch_assoc($query));?>

            </table>





            <?php } ?>

                <?php if($total==0){ ?>
                    <p>Não foram encontrados registos</p>
                    <?php } ?>
    </body>

    </html>

    <?php
mysqli_close($connect);
mysqli_free_result($query);
?>

Sem comentários:

Enviar um comentário