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. Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.