I'm attempting to introduce a system in which the user's latest security information is printed from database.
Context: MYSQL and PHP
The database looks a little like this...
id username dateTime ipAddress country region city
1 salieri 05/09/2021 10:41 1.1.1.1 GB England London
2 salieri 06/09/2021 10:23 1.1.1.1 GB England Hackney
How would I make it so that the highest ID (or latest date time) for a particular user is echo'd?
I'm currently using this code but it will only pull the first value for that user from the database-- doing quite the opposite of what I would like.
//security data
$securityQuery = "SELECT * FROM logInAttempts WHERE username='{$_SESSION['username']}' ";
$securityResults = mysqli_query($connection, $securityQuery);
if(mysqli_num_fields($securityResults) > 1) {
$securityRes = mysqli_fetch_array($securityResults);
}