Page 1 of 1

Displaying online users count in specified Chatroom with PHP

PostPosted: 05 Aug 2020, 04:05
by andygrainger
Hi there,

Just wondering if anyone has done this already?

Displaying online users count in specified Chatroom with PHP.

In the \includes\json\receive\receive_chatroom_list.php file under START CHATROOM LIST RECEIVE there is code to query the database for the current users list but with my limited PHP coding knowledge - not 100% sure how to modify it to update a variable with just the user count (and ideally usernames). I want to pass this back to my integrated site (MyBB) so will probably add the code directly into one of its .php files.

Many thanks for your help in advance.

Re: Displaying online users count in specified Chatroom with PHP

PostPosted: 05 Aug 2020, 04:28
by jvdend
Code: Select all
$chatcafe_online=0;
$sql = "SELECT COUNT(user_id) FROM arrowchat_chatroom_users WHERE (chatroom_id='1' AND session_time > (" . time() . " - 70))";
//$result = mysqli_query($sql);
$result = $db->sql_query($sql);
$row = mysqli_fetch_array($result);
$chatcafe_online = $row[0];