[eluser]davidbehler[/eluser]
Actually you can't track in real time who is online and who is not (well...you could do that using javascript but let's say you only want to use php and mysql) but you can track who was online in the last 5 minutes. All you need is a column in your user table of the type timestamp or datetime that you update each time the user logs in/moves on your site.
And then you can use something like this to determine who has been online in the last 5 minutes:
Code:
SELECT * FROm user_table WHERE DATE_ADD(datetime_column, INTERVAL 5 MINUTE) >= NOW();
As far as I know that (or something similar) is how it's done most of the time/how I usually do it.