I am building a login/signup site with PDO just for fun on wamp...
I am currently building a users online page, when a user accesses any member page it updates a column called online in my mysql table with a unix timestamp.
On the users online page I am trying to find and show all the users who qualify for being online which is being active in the last ten minutes. So far I have this...
$online_users = time() - 600; $q = $dbc -> prepare("SELECT * FROM accounts WHERE online > ?"); $q -> execute(array($online_users)); $online_user = $q -> fetch(PDO::FETCH_ASSOC); while ($q) { echo '<p> ' . $player_details['username'] . ' is online.</p>'; } The problem I am having is that it is looping over and over again, I would like it to loop through the table once, and display all the users who the mysql query only once...
I am new to PDO and am self learning, so if it is something really daft please excuse me!
Thanks in advance...
notice's?$online_userand reading it from$player_details. PHP can warn you about it and help you save time and headaches: have a look at error_reporting().