3
I have a table where I store access permissions to a system. It’s like this:
So far so good, but by listing the permissions of each user ( only has 02 registered users ) in the view of administrators, is bringing duplicity of data. The code I’m using is:
while($jmVisualizar = mysqli_fetch_object($sqlAdm)){
$sqlPermissao = mysqli_query($this->conexao,"SELECT * FROM permissao_adm
WHERE IDAdministrador = '".$jmVisualizar->IdAdmin."';");
$jmPermissao = mysqli_fetch_object($sqlPermissao);
if($jmPermissao->Cadastrar == '1'){
$visualiza[] = "Cadastrar";
}if($jmPermissao->Visualizar == '1'){
$visualiza[] = "Visualizar";
}if($jmPermissao->Editar == '1'){
$visualiza[] = "Editar";
}if($jmPermissao->Excluir == '1'){
$visualiza[] = "Excluir";
}
// Testar
echo implode(",", $visualiza)."<br>";
}
He’s calling me back:
Cadastrar,Visualizar,Editar,Excluir
Cadastrar,Visualizar,Editar,Excluir,Visualizar,Editar
When in fact it is to return me:
Cadastrar,Visualizar,Editar,Excluir
Visualizar,Editar
Thanks Inkeliz, it worked!
– user24136