Google

NukeCoder


View next topic
View previous topic
Post new topic   Reply to topic
Author Message
kenny




Joined: Jan 17, 2008
Posts: 4

PostPosted: Sun Jan 20, 2008 1:16 pm
Reply with quote

Hi there is there a simple way to get how many users there in the chat and show it in the user info block
 
View user's profile Send private message
gotcha
Site Admin
Site Admin



Joined: Oct 25, 2004
Posts: 921

PostPosted: Sun Jan 20, 2008 6:17 pm
Reply with quote

Yeah, you can check the users online like this...

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); 


You can then use $chat_user_count to display it where you want.
 
View user's profile Send private message Visit poster's website
nimis




Joined: Jan 20, 2008
Posts: 5

PostPosted: Wed Jan 23, 2008 7:26 pm
Reply with quote

gotcha wrote:
Yeah, you can check the users online like this...

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); 


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.



Image
 
View user's profile Send private message
gotcha
Site Admin
Site Admin



Joined: Oct 25, 2004
Posts: 921

PostPosted: Wed Jan 23, 2008 9:21 pm
Reply with quote

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.
 
View user's profile Send private message Visit poster's website
kenny




Joined: Jan 17, 2008
Posts: 4

PostPosted: Wed Jan 23, 2008 11:59 pm
Reply with quote

Many thanks for both the chat and for the code it works like a charm Very Happy
 
View user's profile Send private message
corpse




Joined: Apr 06, 2008
Posts: 33

PostPosted: Wed Apr 30, 2008 5:02 am
Reply with quote

gotcha wrote:
Yeah, you can check the users online like this...

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); 


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.
 
View user's profile Send private message Visit poster's website
Guardian




Joined: Dec 09, 2006
Posts: 335

PostPosted: Wed Apr 30, 2008 1:23 pm
Reply with quote

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 
View user's profile Send private message
corpse




Joined: Apr 06, 2008
Posts: 33

PostPosted: Wed Apr 30, 2008 10:49 pm
Reply with quote

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.
 
View user's profile Send private message Visit poster's website
gotcha
Site Admin
Site Admin



Joined: Oct 25, 2004
Posts: 921

PostPosted: Thu May 01, 2008 6:19 am
Reply with quote

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.
 
View user's profile Send private message Visit poster's website
Guardian




Joined: Dec 09, 2006
Posts: 335

PostPosted: Thu May 01, 2008 6:45 am
Reply with quote

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 
View user's profile Send private message
corpse




Joined: Apr 06, 2008
Posts: 33

PostPosted: Thu May 01, 2008 1:56 pm
Reply with quote

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>";
?>
 
View user's profile Send private message Visit poster's website
Guardian




Joined: Dec 09, 2006
Posts: 335

PostPosted: Thu May 01, 2008 2:13 pm
Reply with quote

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 
View user's profile Send private message
corpse




Joined: Apr 06, 2008
Posts: 33

PostPosted: Thu May 01, 2008 4:16 pm
Reply with quote

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.
 
View user's profile Send private message Visit poster's website
gotcha
Site Admin
Site Admin



Joined: Oct 25, 2004
Posts: 921

PostPosted: Thu May 01, 2008 4:20 pm
Reply with quote

Nope, it should just display the number of users in chat.
 
View user's profile Send private message Visit poster's website
corpse




Joined: Apr 06, 2008
Posts: 33

PostPosted: Thu May 01, 2008 4:22 pm
Reply with quote

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>";
?>
 
View user's profile Send private message Visit poster's website
Display posts from previous:       
Post new topic   Reply to topic

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 5 Hours
Forums ©