| Author |
Message |
kenny
Newbie


Joined: Jan 17, 2008
Posts: 4
|
Posted:
Mon Jan 21, 2008 4:16 am |
|
Hi there is there a simple way to get how many users there in the chat and show it in the user info block |
|
|
|
 |
gotcha
Site Admin


Joined: Oct 25, 2004
Posts: 727
|
Posted:
Mon Jan 21, 2008 9:17 am |
|
Yeah, you can check the users online like this...
$query2 = 'SELECT COUNT(username) FROM '.$prefix.'_live_online WHERE timestamp>\''.(time() - 60).'\' ORDER BY username ASC';
$result2 = $db->sql_query($query2);
list($chat_user_count) = $db->sql_fetchrow($result2);
You can then use $chat_user_count to display it where you want. |
|
|
|
 |
nimis
Newbie


Joined: Jan 20, 2008
Posts: 5
|
Posted:
Thu Jan 24, 2008 10:26 am |
|
| gotcha wrote: |
Yeah, you can check the users online like this...
$query2 = 'SELECT COUNT(username) FROM '.$prefix.'_live_online WHERE timestamp>\''.(time() - 60).'\' ORDER BY username ASC';
$result2 = $db->sql_query($query2);
list($chat_user_count) = $db->sql_fetchrow($result2);
You can then use $chat_user_count to display it where you want. |
Thanks for your reply pointing to tis post gotcha.. but I need a little help.
Where should this be placed.
I am not using the block itself as a chat, I got the module in the Navagation block as a link .
Hope I havent confussed you.
 |
|
|
|
 |
gotcha
Site Admin


Joined: Oct 25, 2004
Posts: 727
|
Posted:
Thu Jan 24, 2008 12:21 pm |
|
Well, if that is just the standard modules block there isn't really an easy way to do that as it loops through the database to build the menu. You would probably need a custom menu to get something like that. Another option would be to put the chat count somewhere in the header or in its own block, or the user info block like kenny wanted to do. |
|
|
|
 |
kenny
Newbie


Joined: Jan 17, 2008
Posts: 4
|
Posted:
Thu Jan 24, 2008 2:59 pm |
|
Many thanks for both the chat and for the code it works like a charm  |
|
|
|
 |
corpse
Repeat Offender

Joined: Apr 06, 2008
Posts: 30
|
Posted:
Wed Apr 30, 2008 8:02 pm |
|
| gotcha wrote: |
Yeah, you can check the users online like this...
$query2 = 'SELECT COUNT(username) FROM '.$prefix.'_live_online WHERE timestamp>\''.(time() - 60).'\' ORDER BY username ASC';
$result2 = $db->sql_query($query2);
list($chat_user_count) = $db->sql_fetchrow($result2);
You can then use $chat_user_count to display it where you want. |
how would i go about coding that to work in a block, my 3 attempts failed. I know i am doing some wrong, probably a stupid mistake.
I am just trying to have the Users that are online chatting display in a block. |
|
|
|
 |
Guardian
Mr. Awesome

Joined: Dec 09, 2006
Posts: 240
|
Posted:
Thu May 01, 2008 4:23 am |
|
If I remember correctly, nukes blocks use $content to cho data to the browser so you might have to add after that
| Code: |
| $content = $$chat_user; |
|
_________________ Code Authors Nuke Reviews |
|
|
 |
corpse
Repeat Offender

Joined: Apr 06, 2008
Posts: 30
|
Posted:
Thu May 01, 2008 1:49 pm |
|
That was what I tried first,
| Code: |
<?php
$query2 = 'SELECT COUNT(username) FROM '.$prefix.'_live_online WHERE timestamp>\''.(time() - 60).'\' ORDER BY username ASC';
$result2 = $db->sql_query($query2);
list($chat_user_count) = $db->sql_fetchrow($result2);
OpenTable();
echo "<center>";
$content = $chat_user_count;
echo "</center>";
CloseTable();
?> |
What it does is dispaly nothing and actually makes my right blocks and my center stuff disapear.
I tried it with and with out the "open table" with no luck. |
|
|
|
 |
gotcha
Site Admin


Joined: Oct 25, 2004
Posts: 727
|
Posted:
Thu May 01, 2008 9:19 pm |
|
In blocks you want to avoid any "echo". Try this instead...
| Code: |
$query2 = 'SELECT COUNT(username) FROM '.$prefix.'_live_online WHERE timestamp>\''.(time() - 60).'\' ORDER BY username ASC';
$result2 = $db->sql_query($query2);
list($chat_user_count) = $db->sql_fetchrow($result2);
$content .= "<center>Users In Chat: ";
$content .= $chat_user_count;
$content .= "</center>"; |
Using the .= instead of just = will add to $content instead of overwriting it. |
|
|
|
 |
Guardian
Mr. Awesome

Joined: Dec 09, 2006
Posts: 240
|
Posted:
Thu May 01, 2008 9:45 pm |
|
Wow, I cannot believe the number of typo's in my earlier post - too much beer I think.
Just in case gotcha's code doesn't work (it should in theory) you may have to remove the . before the = on the first $content line. |
_________________ Code Authors Nuke Reviews |
|
|
 |
corpse
Repeat Offender

Joined: Apr 06, 2008
Posts: 30
|
Posted:
Fri May 02, 2008 4:56 am |
|
Okay, I tried that, and all it does is still makes the right and center blocks disappear. I tried something different and now it wont make the blocks disappear, but it also displays the block, but not the users on there. I feel I took a step forward and 2 back. But this is what I got to eliminate the disappearing act of my website.
| Code: |
<?PHP
if ( eregi( "block-whos_chatting.php", $PHP_SELF ) )
{
Header(" Location: index.php" );
die();
}
global $db;
$result = $db->sql_query = 'SELECT COUNT(username) FROM '.$prefix.'_live_online WHERE timestamp>\''.(time() - 60).'\' ORDER BY username ASC';
list($chat_user_count) = $db->sql_fetchrow($result);
$content = "<center>Users In Chat: ";
$content .= "$chat_user_count";
$content .= "</center>";
?> |
|
|
|
|
 |
Guardian
Mr. Awesome

Joined: Dec 09, 2006
Posts: 240
|
Posted:
Fri May 02, 2008 5:13 am |
|
Here is the code I just tried on my own site which is working with RavenNuke. You wil obviously need to add the start and end PHP tags.
| Code: |
if ( !defined('BLOCK_FILE') ) {
Header('Location: ../index.php');
die();
}
global $db, $prefix;
$result = $db->sql_query = 'SELECT COUNT(username) FROM '.$prefix.'_live_online WHERE timestamp>\''.(time() - 60).'\' ORDER BY username ASC';
list($chat_user_count) = $db->sql_fetchrow($result);
$content ="<center>Users In Chat: ";
$content .=$chat_user_count;
$content .="</center>"; |
|
_________________ Code Authors Nuke Reviews |
|
|
 |
corpse
Repeat Offender

Joined: Apr 06, 2008
Posts: 30
|
Posted:
Fri May 02, 2008 7:16 am |
|
Should it display your name if you were to be in it?
If so, then nope, not working. I am running phpnuke, 7.9 with the latest patch and sentinel.
strange if it working on your ravennuke and not on 7.9. I may try uploading this on my test site to see if it works there. |
|
|
|
 |
gotcha
Site Admin


Joined: Oct 25, 2004
Posts: 727
|
Posted:
Fri May 02, 2008 7:20 am |
|
Nope, it should just display the number of users in chat. |
|
|
|
 |
corpse
Repeat Offender

Joined: Apr 06, 2008
Posts: 30
|
Posted:
Fri May 02, 2008 7:22 am |
|
nope, no numbers, no nothing. Just blank under it.
this is the HTML output from the source view.
| Code: |
<center>Users In Chat: </center></font></td>
</tr>
</tbody></table></td>
</tr>
<tr>
<td background="themes/BlackW/images/u3.gif" height="23"> </td> |
**EDIT**
This is exactally how I have the block.
| Code: |
<?PHP
if ( !defined('BLOCK_FILE') ) {
Header('Location: ../index.php');
die();
}
global $db, $prefix;
$result = $db->sql_query = 'SELECT COUNT(username) FROM '.$prefix.'_live_online WHERE timestamp>\''.(time() - 60).'\' ORDER BY username ASC';
list($chat_user_count) = $db->sql_fetchrow($result);
$content ="<center>Users In Chat: ";
$content .= $chat_user_count;
$content .="</center>";
?>
|
|
|
|
|
 |
|
|