danx30 Posted November 4, 2009 Share Posted November 4, 2009 What I'm trying to do is have a section of my website to list the last 10 users of the page. The users are saved into a mysql database. There are thousands of users but only want it to show the last 10. For some reason this is stumping me. I'm just not sure how to approach it. Any help would be appreciated. Link to comment https://forums.phpfreaks.com/topic/180320-last-10-users-code/ Share on other sites More sharing options...
simshaun Posted November 4, 2009 Share Posted November 4, 2009 Last 10 users that *what*? Last 10 who have logged in? Update a timestamp in the db upon login and run a query such as SELECT id FROM users ORDER BY last_login DESC LIMIT 10. Link to comment https://forums.phpfreaks.com/topic/180320-last-10-users-code/#findComment-951218 Share on other sites More sharing options...
Stuie_b Posted November 4, 2009 Share Posted November 4, 2009 if its a case of the last 10 registered users, you could run a query and limit it to 10 for example <?php $qh = mysql_query("SELECT * FROM members_table WHERE active='1' LIMIT 0,10"); while($ret = mysql_fetch_array($qh)){ echo $ret['username']; } ?> Stuie Link to comment https://forums.phpfreaks.com/topic/180320-last-10-users-code/#findComment-951220 Share on other sites More sharing options...
danx30 Posted November 4, 2009 Author Share Posted November 4, 2009 Thanks, I figured out how to do it. You helped me get unstuck. Link to comment https://forums.phpfreaks.com/topic/180320-last-10-users-code/#findComment-951228 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.