Help
Discuss or request ArrowChat modifications
User avatar
Worthy
Customer
 
Posts: 9
Joined: 22 Jun 2013, 11:37

 

by Worthy 22 May 2017, 04:40

Hello Jason,

How can I do a call to grab JUST the total number of chatters in a chat room?

The reason being, I used to run an Invision Power Board chat room -- before they shut it down.

I'm very pleased with Arrowchat as being a more than adequate replacement of the chat room.

One thing they used to do is show the number of chatters in a "notification bubble" within the chat tab to show how many users were in the chat room at any time.

Right now, I placed the embed script that shows users online (on arrowchat) on my forums which displays their avatars -- but I would like to grab JUST the number of chatters from the Database -- then display just the number on my site.

What's the best way to grab it?

Thanks,

Worthy
User avatar
Worthy
Customer
 
Posts: 9
Joined: 22 Jun 2013, 11:37

 

by Worthy 25 May 2017, 12:06

This is a code I wrote to grab the number of chatters currently online --

<?php

$servername = "localhost";
$username = "usernsame";
$password = "password";
$dbname = "database";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

$chatters_online = 0;

$sql = "SELECT * FROM `arrowchat_chatroom_users` WHERE `session_time` > ( UNIX_TIMESTAMP() - 360 )";

$result = $conn->query($sql);

$row_cnt = mysqli_num_rows($result);

$chatters_online = $row_cnt;

echo $chatters_online;

$result->free();

$conn->close();

?>

Now off to try and connect the ID's listed to the database member names.

But this can be a simple include to display those in the chat room at any given time.

Worthy
User avatar
Worthy
Customer
 
Posts: 9
Joined: 22 Jun 2013, 11:37

 

by Worthy 25 May 2017, 12:24

Any ideas of the best way to array out the Id's with their usernames? Any thoughts anyone?
User avatar
Worthy
Customer
 
Posts: 9
Joined: 22 Jun 2013, 11:37

 

by Worthy 30 May 2017, 05:55

Code: Select all
<?php

$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "database_nam";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

$chatters_online = 0;

$sql = "SELECT `name` from `table where name id is located in forum software` WHERE `member_id` IN (SELECT `user_id` FROM `arrowchat_chatroom_users` WHERE `session_time` > ( UNIX_TIMESTAMP() - 360 ));";
$i = 1;
$result = $conn->query($sql);

$row_cnt = mysqli_num_rows($result);

$chatters_online = $row_cnt;

while ($row = $result->fetch_array())
   {
   echo $row['0'];

if ($i < $row_cnt)
   {
       echo ', ';
   }

   $i ++;
}
   
echo "<br /><br /><strong>Total number of chatters online: ";
echo $chatters_online;
echo "</strong>";

$result->free();

$conn->close();

?>




This returns the names, and the total number of chatters which I used for Invision Power Board and placed it on the forums as an include.
User avatar
PPlanet
Customer
 
Posts: 9
Joined: 03 May 2017, 07:54

 

by PPlanet 17 Jun 2017, 06:35

Do you mind letting me know where I can place this code if using IPB 3.4? Thanks.