Taking only the last record

Asked

Viewed 36 times

0

I’m using this code to get the data between the current time and time registered in the comic

$sql = "SELECT * FROM acessos WHERE hora > :hora GROUP BY username";
$sql = $pdo->prepare($sql);
$sql->bindValue(":hora", date('H:i:s', strtotime("-1 minutes")));
$sql->execute();
$contagem = $sql->rowCount();

while($row = $sql->fetch()) {
    $teste = $row['username'].', ';
}

But the problem that’s only getting the last record, and I couldn’t solve

  • What you get if you take GROUP BY username of query?

  • Please give more details about the table and how you want to return this data. For example, why are you doing this group by?

1 answer

1


  • Thanks Felipe, solved my problem :)

  • Good to know if you can read this link https://answall.com/help/someone-answers to find out how to proceed after your question has been answered ;)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.