You are trying to show "Currently logged in users" is that correct?
It isn't very easy to pull off in php. You would have to update the database with every page visit to keep track of when someone is online. You could create a plugin file to do this for you and include it on the top of every page.
First add a column to your users table "UserLastVisit" and make it a Date/Time data type or timestamp.
UPDATE users SET UserLastVisit= NOW() WHERE UserID = IDSavedOnLogin
Then to get how many people are on the site at any given moment you use a recordset with the query:
SELECT COUNT(*) AS CurrentUsers FROM users WHERE UserLastVisit> DATE_SUB(NOW(), INTERVAL 20 MINUTE)