FROM atributos, tipos_de_atributo
WHERE atributos.idTipoAtributo = tipos_de_atributo.id
-- Não se esqueçam de criar a vista v1_atributos com o sql em cima
<?php
require_once("sistema.php");
$sql="SELECT * FROM v1_atributos";
$query=mysqli_query($ligar, $sql);
$total=mysqli_num_rows($query);
$fetch=mysqli_fetch_assoc($query);
?>
<!DOCTYPE html>
<html lang="pt">
<head>
<meta charset="UTF-8">
<title>Listar atributos</title>
</head>
<body>
<a href="index.php">Voltar</a>
</body>
</html>
Atualização 2
<?php
require_once("sistema.php");
$sql="SELECT * FROM v1_atributos";
$query=mysqli_query($ligar, $sql);
$total=mysqli_num_rows($query);
$fetch=mysqli_fetch_assoc($query);
?>
<!DOCTYPE html>
<html lang="pt">
<head>
<meta charset="UTF-8">
<title>Listar atributos</title>
</head>
<table border="1" cellpadding="5">
<tr>
<th>Tipo de atributo</th>
<th>Atributo</th>
<th>Estado</th>
</tr>
<?php do { ?>
<tr>
<td><?php echo $fetch['tipoAtributo'];?></td>
<td><?php echo $fetch['atributo'];?></td>
<td><?php
if($fetch['estado']==0){echo "Inativo";}
if($fetch['estado']==1){echo "Ativo";}
?></td>
</tr>
<?php } while($fetch=mysqli_fetch_assoc($query));?>
</table>
<body>
<a href="index.php">Voltar</a>
</body>
</html>
atualização 3
<?php
// atributosAlterarEstado.php
require_once("sistema.php");
if(isset($_GET['alterar'])){ // gatilho
$estado=$_GET['estado'];
$idAtributo=$_GET['idAtributo'];
if($estado==0){
$estado=1;
}else{
$estado=0;
}
$sql="UPDATE atributos SET estado=$estado WHERE id =$idAtributo";
mysqli_query($ligar, $sql);
$caminho="atributoListar.php?alterado";
} else{
$caminho="index.php";
}
header("Location:$caminho");
?>
Sem comentários:
Enviar um comentário