Hello.
I'm having trouble displaying the result of a query in the database.
I have 2 tables
Tabela 1 - logs // logs do sistema
//user_id = são os usuários administrativos do sistema
//user_perfil = é o perfil do usuário que usa o sistema (cliente).
id | user_id | user_perfil
1 | 10 | 105
2 | 10 | 106
3 | 12 | 105
4 | 12 | 104
Tabela 2 - user
id | nome
10 | Luiz
11 | Renato
12 | Marcio
I have a screen that displays the result through the GET client profile ID, which fetches the information through another table that is the user profile, which displays the name and other information.
The detail here is to view the admin access log to see who has viewed this profile. For this I created the logs table, which every time the administrator accesses this profile writes the user_id - of the administrator and the user_perfil - of the client profile. save only, not repeat.
The logic would be as follows, through the GET generates the profile ID, and writes in the database logs, administrator id (session) and the profile's Get ID.
Show only who saw, in my case with while it is displaying all the administrators, I used GROUP BY, not to repeat the data.
I would like to display the name of the administrator who viewed the user's profile. I tried to do the while below, but it's not rolling. No error occurs, it displays only the name of each administrator. Type the user Luiz viewed profile 105 and 106, and Marcio viewed 105 and 104, when accessing profile 105 should display Luiz and Marcio, and profile 106 only Luiz, but in all profile this is displaying Luiz, Marcio and Renato.
Can anyone help me? Thanks
Follow the while I did:
$situacao_atual = $row_logs['user_id'];
$result_logs = "SELECT * FROM user WHERE id = '$situacao_atual'";
$result_logs = mysqli_query($conn, $result_logs);
$row_user = mysqli_fetch_assoc($result_logs);
//$row_logs = mysqli_fetch_assoc($result_logs);
$iduser = $row_logs['user_perfil'];
if($idcurriculo = $id){
echo $row_usuarios['nome'];
}
else {echo "no";}
}