I have the following tables: permissoes_users
- id_user
- id_permission
permissions id - Permission
I have a session variable where I have the id di user, I need to search the table for the id and those that have the id of the user to display the name of the permission ... How can I do it?
Error testing first response:
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>