segunda-feira, 19 de março de 2018

ECD dia 19 de março de 2018

<?php
// http://localhost:8080/aula-9-10/usersListar.php
require_once("ligacao.php");
$sql="SELECT * FROM v1_users ORDER BY nome, apelido ";
$query=mysqli_query($ligarECD, $sql) or die ("Erro 2");
$total=mysqli_num_rows($query);
if($total>0){
    $fetch=mysqli_fetch_assoc($query);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> 
</head>
<body>
    <div class="container">
        <?php if($total==0){?>
        <div>
        <p>Não há registos para apresentar.</p>
        </div>
        <?php } elseif($total>0){?>
        <div id="tabelaUsers">
        <!-- A minha tabela -->
        <table class="table">
            <thead>
            <tr>
                <th></th>
                <th>#</th>
                <th>Nome</th>
                <th>Apelido</th>
                <th>Username</th>
                <th>Privilégio</th>
                <th>Estado</th>
            </tr>
            </thead>
             <tbody>
            <?php $i=0; do { $i++;?>
            <tr>
             
          <td><a href="usersAlterar.php?idUser=<?php echo $fetch['idUser'];?>">Alterar</a></td>             
               
                <td><?php echo $i;?></td>
                <td><?php echo $fetch['nome'];?></td>
                <td><?php echo $fetch['apelido'];?></td>
                 <td><?php echo $fetch['username'];?></td>
                 <td><?php echo $fetch['privilegio'];?></td>
                <td><?php if($fetch['estadoUser']==1){
                                echo "Ativo";}
                            else {
                                echo "Inativo";}?>
                                </td>
            </tr>
            <?php } while($fetch=mysqli_fetch_assoc($query));?>
            </tbody>
        </table>
        </div>
        <?php }?>
       
    </div> 
                     
</body>
</html>
















Sem comentários:

Enviar um comentário