I have the following PHP script that selects MySQL data and displays all the different users' data in a table.
What I need is to limit this data to only that of the logged-in user for that session. As in only the single ID, name and email of the person logged in instead of the table showing all user data.
I assume I need to "SELECT * FROM usertable where (something) = (something)", I'm just not sure where to go from here.
Any help would be appreciated.
<?php
$con=mysqli_connect("localhost","myusername","mypassword","mydatabase");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM usertable");
echo "<table border='1'>
<tr>
<th>ID</th>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['firstname'] . "</td>";
echo "<td>" . $row['lastname'] . "</td>";
echo "<td>" . $row['emailaddress'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>