MyBB Community Forums

Full Version: Online Users
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

Created a website around MyBB and is now fully integrated and working. My index.php consists of a login form to create a session for MyBB. My only question is...

How do I add the users online to the index.php page? I would like visitors and members to know how many people are online at that moment before logging in.

I have changed the language from what was the original to There are {1} {2} at the moment.

I'm a real noob at this, some help would be much appreciated as I've been looking for hours on Google, forums and still can't find anything suitable.

You've to run a query to fetch the online users from database. Then you'll be able to show them on your website's main page.
I'm sorry, not very experienced with SQL, could you let me know what query I have to fetch?
You've to run a query something like this;
		$timesearch = TIME_NOW - $mybb->settings['wolcutoffmins']*60;
		$sql = "u.username ASC, s.time DESC";
		$query = $db->query("
			SELECT u.username, u.uid
			FROM ".TABLE_PREFIX."users u
			LEFT JOIN ".TABLE_PREFIX."sessions s ON (s.uid=u.uid)
			WHERE s.time > '$timesearch'
			ORDER BY $sql");

The you'll have to manipulate it further.
I have no idea how to manipulate such queries, I'm very new to MySQL. If it's going to be too fiddly to do what I thought would have been a simple task, maybe I should just forget about it. Possibly not worth the hassle.
Open index.php, all the code you need is in there.
Thanks Malcolm, is it as simple as copying and pasting the part of the online users to my website's index.php?

I've tried this, possible put it in the wrong section. In all honest, I look at the code in my website's index.php and it really looks like a dog's dinner, but it works so far so I can't complain.

I did try to add the variable in the index.php page. Everything loaded fine apart from that variable, it just left a blank gap/new line.
Just had a second attempt this morning, still having issues.

Anyway willing to share their wisdom? Remember, I'm a n00b at this big time! :-)