quarta-feira, 9 de outubro de 2019

privilegiosListar.php

<?php
#privilegiosListar.php
$table="privilegios";
$sql="SELECT * FROM $table";
require_once("connection.php");
$query=mysqli_query($connect, $sql) or die("Erro em $sql");
$total=mysqli_num_rows($query);
if($total>0){
    $fetch=mysqli_fetch_assoc($query);
}
?>
<?php if($total>0){?>
   <p><?php echo $total;?> registos encontrados</p>
    <table border="1">
        <tr>
            <th>ID</th>
            <th>Privilegio</th>
        </tr>
        <?php do {?>
        <tr>
            <td><?php echo $fetch['id'];?></td>
            <td><?php echo $fetch['privilegio'];?></td>
        </tr>
        <?php } while($fetch=mysqli_fetch_assoc($query));?>
         

    </table>
<?php }?>

<?php if($total==0){?>
<p>Não há registos na tabela</p>
<?php }?>






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

Sem comentários:

Enviar um comentário