Recipe for MySQL based user online status indicator.
Step 1, go to google search for "php get ip address of user"
Step 2, read it until you understand it.
Step 3, go to google, search for "php and mysql tutorial"
Step 4, read it until you understand it.
Step 5, go to google, search for "php date and time example"
Step 6, read it until you understand it.
Step 7, combine all of the knowledge gained to: insert ip's and a timestamp if they are not already in the table.
Step 8, combine all of the knowledge gained to: locate and delete ip addresses older than 15 - 30 minutes.
Step 9, add some code to update the ip if it already exists so that the count does not change if they were viewing pages 5 minutes ago, but initially visited the site 17 minutes ago.
Work through steps 1 - 9 in order, let cool before serving.