## General developer forum

### Show online users in different color

Re: Show online users in different color

A quick script I came up with to show this:

I have taken a dummy course id here and this lists the users who are online or not on that course.

SELECT u.firstname,u.lastname,e.enrol,ue.userid,e.courseid,ue.enrolid, IF(FROM_UNIXTIME(u.lastaccess) > (sysdate() - INTERVAL 5 MINUTE) ,'online','offline') AS 'status', DATE_FORMAT(FROM_UNIXTIME(u.lastaccess),'%d-%m-%Y %H:%i:%s') as 'lastaccess', sysdate() - INTERVAL 5 MINUTE AS '5minearlier', u.lastaccess from mdl5_user u join mdl5_user_enrolments ue on ue.userid = u.id JOIN mdl5_enrol e ON e.id = ue.enrolid where e.courseid = 4554 and u.deleted = 0 ORDER BY u.lastaccess DESC

You can traverese through all the courses the user has and then amend the script to use 'where courseid IN (1,2,3.....)

Hope this helps

Average of ratings: -
Re: Show online users in different color

Sorry for late reply my confusion is in which php page this script goes

Average of ratings: -
Re: Show online users in different color

you would have to make your own block for this ..