I have a table with many different users on my website. They upload the picture. How can I display the last uploaded picture with the highest ID number?
If I do this query:
SELECT user_name, MAX(pictid) FROM `pictures` GROUP BY user_name;
It works in PHP My Admin, but it returns empty result on the website.
Username is written correctly, just ID part is empty. Why is that? That is my code:
include('connection.php');
$sql = "SELECT user_name, MAX(pictid) FROM `pictures` GROUP BY user_name;";
$result = $mysqli->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<tr><td>". $row["user_name"] . "</td><td>". $row["pictid"] . "</td><td><img style='width:90px;' src='../uploads/".$row["picture"]."'</td><tr>";
}
}