I have just started learning PHP, so please bear with me. I have two tables in my database, users
and appointments
tables. The appointments
table has idUsers
as a foreign key for the id
field in users
table. I'm trying to display data from appointments
table based on current user logged in. The problem is, it displays data from all users and not the one who logged in.
I'm using fetch_assoc()
to get the data from the database.
<?php
while($row = $rows->fetch_assoc()): ?>
<td><?php echo $row['idApp'] ?></td>
<td class="col-md-10"><?php echo $row['fname'] ?> </td>
<td class="col-md-10"><?php echo $row['lname'] ?> </td>
<td class="col-md-10"><?php echo $row['email'] ?> </td>
<td class="col-md-10"><?php echo $row['phone'] ?> </td>
<td class="col-md-10"><?php echo $row['date'] ?> </td>
<td class="col-md-10"><?php echo $row['time'] ?> </td>
<td class="col-md-10"><?php echo $row['message'] ?> </td>
</tr>
<?php endwhile; ?>
The expected results would be for the user to log into the system and only see the data , that they have stored against their id.