I have a table where I store access permissions to a system. It looks like this:
Sofarsogood,butlistingthepermissionsofeachuser(onlyhas02usersregistered)intheadministratorsview,isbringingdataduplicity.ThecodeI'musingis:
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 returning me:
Cadastrar,Visualizar,Editar,Excluir
Cadastrar,Visualizar,Editar,Excluir,Visualizar,Editar
When it really comes back:
Cadastrar,Visualizar,Editar,Excluir
Visualizar,Editar