I tried to use this function
$conn = db_connect();
while ($newsfeed = $conn->query("select info, username, time from newsfeed ORDER BY time DESC LIMIT 10"))
{
(...)
echo "<p>User $newsfeed_username just registerted ".$minutes." min ago </p><br>";
but it only shows the latest row over and over again. I want to loop through all the queries from
select info, username, time from newsfeed ORDER BY time DESC LIMIT 10
in descending order.
Here’s the basic template for this kind of thing, using built-in php functions (assuming old-style mysql, but similar using other database back-ends, or higher-level libraries). In this example, errors are handled by throwing exceptions, but that’s just one way to do it.
The exception classes would need to be defined (they’re the only non-built-in syntax here, but you shouldn’t throw plain-vanilla Exceptions).
Example Code: