0
Hello.
I’m having trouble displaying results of a bank consultation.
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 customer profile ID, by GET, which searches the information through another table that is the user profile, which displays the name and other information.
The detail here is to display the administrators access log, to know who has already viewed this profile. For this I created the table logs, which every time the administrator accesses this profile saves the user_id - of the administrator and user_profile - of the client profile. records only, without repeating.
The logic would be as follows, through GET generates the profile ID, and saves in the database logs, administrator id (Session) and the profile ID Get.
Display only who saw, in my case with while it is displaying all administrators, I used GROUP BY, not to repeat the data.
I would like to display the name of the administrator who viewed the user 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 user Luiz viewed the profile 105 and 106, and Marcio viewed 105 and 104, when accessing the profile 105 should display Luiz and Marcio, and profile 106 only Luiz, but in all profile is displaying Luiz, Marcio and Renato.
Can someone help me? Thank you
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";}
}
Because it’s running twice the
$row_user = mysqli_fetch_assoc($result_logs); $row_logs = mysqli_fetch_assoc($result_logs);
?– Guilherme Nascimento
Hello, comment error, should be commented the $row_logs, will be edited the question. thanks
– Marcelo Rossi