2
I have the following tables : permissions_users
- id_user
- id_permissao
permissions - id - permission
I have a session variable where I have the id of user , I need to do a table search for id and those that have the id of the user display the name of the permission... How can I do?
Error testing the first answer:
Notice: Undefined index: permissao in /Applications/XAMPP/xamppfiles/htdocs/DEV WEB/projetoFinalBD/permissao.php on line 51
Notice: Undefined index: permissao in /Applications/XAMPP/xamppfiles/htdocs/DEV WEB/projetoFinalBD/permissao.php on line 51
Notice: Undefined index: permissao in /Applications/XAMPP/xamppfiles/htdocs/DEV WEB/projetoFinalBD/permissao.php on line 51
Notice: Undefined index: permissao in /Applications/XAMPP/xamppfiles/htdocs/DEV WEB/projetoFinalBD/permissao.php on line 51
Notice: Undefined index: permissao in /Applications/XAMPP/xamppfiles/htdocs/DEV WEB/projetoFinalBD/permissao.php on line 51
Notice: Undefined index: permissao in /Applications/XAMPP/xamppfiles/htdocs/DEV WEB/projetoFinalBD/permissao.php on line 51
Notice: Undefined index: permissao in /Applications/XAMPP/xamppfiles/htdocs/DEV WEB/projetoFinalBD/permissao.php on line 51
Notice: Undefined index: permissao in /Applications/XAMPP/xamppfiles/htdocs/DEV WEB/projetoFinalBD/permissao.php on line 51
Notice: Undefined index: permissao in /Applications/XAMPP/xamppfiles/htdocs/DEV WEB/projetoFinalBD/permissao.php on line 51
Notice: Undefined index: permissao in /Applications/XAMPP/xamppfiles/htdocs/DEV WEB/projetoFinalBD/permissao.php on line 51
Complete code :
<body>
<?php
$id_user = $_GET['id_user'];
function user_info_gamb ($id_user) {
$sql = mysql_query("SELECT * FROM usuarios WHERE id_user = '$id_user'");
return mysql_fetch_assoc($sql);
}
$nome = user_info_gamb($id_user);
//$permissao_pg = 1; include('funcoes/restringirpg.php');
?>
<div id="topo">
<?php echo "Bem - Vindo " . $nome["nome"]; include('funcoes/menu.php');?>
</div>
<div id="conteudo">
<table class="table-auto table-striped text-center" width="auto" border="0" align="center" >
<tr>
<td><strong>PERMISSÕES</strong></td>
</tr>
<?php
function permissao_info ($id_permissao) {
$sql = mysql_query("SELECT * FROM permissoes WHERE id = '$id_permissao'");
return mysql_fetch_assoc($sql);
}
$aux = 0;
$permissoes = mysql_query(" SELECT PU.ID_USER, P.PERMISSAO FROM PERMISSOES_USERS PU INNER JOIN PERMISSOES P ON PU.ID_PERMISSAO = P.ID ");
for ($i=0; $row=mysql_fetch_assoc($permissoes); $i++){$permissao = $row["permissao"];
echo "
<tr>
<td>$permissao</td>
</tr>
";
}
?>
</table>
went wrong ....
– Augusto Furlan
Saying "went wrong" is not enough right. What went wrong?
– Jéf Bueno
I just added the error message to the question
– Augusto Furlan