Welcome to the RaGEZONE - MMORPG development forums.

Users Online SQL

This is a discussion on Users Online SQL within the Habbo Releases forums, part of the Habbo Hotel category; I know this is no big release but this I'm very proud of because i cant do SQL I was ...

LyncusMU
Page 1 of 2 12 LastLast
Results 1 to 15 of 25
  1. #1
    In the Habbo Section
    Rank
    Member +
    Join Date
    Sep 2011
    Location
    Liverpool, UK
    Posts
    458
    Liked
    44

    Users Online SQL

    Tabo Hotel
    I know this is no big release but this I'm very proud of because i cant do SQL I was just messing around with the code
    This is very helpful if you want it to look different on a certain page not just [[0 user(s) online]]
    Now you can have something like [[There is 0 online]]
    HERE :
    Code:
    <?php 
    $getOnline = dbquery("SELECT * FROM users WHERE online = '1'");
    $Online = mysql_num_rows($getOnline)
    ?> 
    <?php echo $Online; ?> [[add your custom thing such as just ONLINE]]
    Also the amount of users registered (Not my work)
    Code:
    $getUsers = mysql_query("SELECT * FROM users"); 
    $users = mysql_num_rows($getUsers); 
    ?> 
    <?php echo $users; ?> [[add your custom thing such as just REGISTERED]]
    Don't Flame give your Opinion !
    Last edited by tomsaundo; 05-11-11 at 04:49 PM.

  2. HostKey.com: Unmetered Dedicated servers in the Netherlands
  3. #2
    PHP, HTML5, CSS3, JS, C#
    Rank
    Alpha Member
    Join Date
    Jun 2010
    Location
    The Netherlands
    Posts
    1,814
    Liked
    1013

    Re: Users Online SQL

    PHP Code:
    echo mysql_result(mysql_query('SELECT COUNT(*) FROM `users` WHERE `online` = "1"'), 00).' people online'
    I thought that does the same =3

    But also, You can just download phoenixphp/ubercms, It has also a user online counter in it?

  4. #3
    In the Habbo Section
    Rank
    Member +
    Join Date
    Sep 2011
    Location
    Liverpool, UK
    Posts
    458
    Liked
    44

    Re: Users Online SQL

    In ubercms you can put %hotelstaus% (i think) and it does it automatically but this is if you want a different one

  5. #4
    PHP, HTML5, CSS3, JS, C#
    Rank
    Alpha Member
    Join Date
    Jun 2010
    Location
    The Netherlands
    Posts
    1,814
    Liked
    1013

    Re: Users Online SQL

    Quote Originally Posted by tomsaundo View Post
    In ubercms you can put %hotelstaus% (i think) and it does it automatically but this is if you want a different one
    That's because it is in a template x.x and already coded into the template system from uber ;/

  6. #5
    In the Habbo Section
    Rank
    Member +
    Join Date
    Sep 2011
    Location
    Liverpool, UK
    Posts
    458
    Liked
    44

    Re: Users Online SQL

    I know that the point of this release
    ( This is my FIRST sql attempt )

  7. #6
    C-images website soon
    Rank
    Member +
    Join Date
    May 2010
    Location
    England, UK
    Posts
    1,285
    Liked
    166

    Re: Users Online SQL

    does this update when users come on and off, or do you have to reload the page?

  8. #7
    PHP, HTML5, CSS3, JS, C#
    Rank
    Alpha Member
    Join Date
    Jun 2010
    Location
    The Netherlands
    Posts
    1,814
    Liked
    1013

    Re: Users Online SQL

    Quote Originally Posted by JohnHearfield View Post
    does this update when users come on and off, or do you have to reload the page?
    What do you thing? php is server side so you must reload or you must use xmlrequest

  9. #8
    C-images website soon
    Rank
    Member +
    Join Date
    May 2010
    Location
    England, UK
    Posts
    1,285
    Liked
    166

    Re: Users Online SQL

    so life is refreshing pages to see whos online.

  10. #9
    Look at me now!
    Rank
    Member +
    Join Date
    Apr 2010
    Location
    Hablow
    Posts
    1,174
    Liked
    127

    Re: Users Online SQL

    Nice! I know this isn't a Pro release, but it is great for a beginner.

  11. #10
    Developer
    Rank
    Member +
    Join Date
    May 2008
    Posts
    482
    Liked
    201

    Re: Users Online SQL

    If ur using the phoenix emu then i think this query is faster, especially if ur user db is large...

    PHP Code:
    SELECT users_online FROM server_status 
    so....
    PHP Code:
    <?php 
    $getOnline 
    dbquery("SELECT users_online FROM server_status");
    $Online mysql_num_rows($getOnline)
    ?> 
    <?php echo $Online?>

  12. #11
    MEHHREKHwhgfkehrkgthregir
    Rank
    Member +
    Join Date
    Sep 2011
    Location
    υηιтє∂
    Posts
    927
    Liked
    305

    Re: Users Online SQL

    Quote Originally Posted by leenster View Post
    If ur using the phoenix emu then i think this query is faster, especially if ur user db is large...

    PHP Code:
    SELECT users_online FROM server_status 
    so....
    PHP Code:
    <?php 
    $getOnline 
    dbquery("SELECT users_online FROM server_status");
    $Online mysql_num_rows($getOnline)
    ?> 
    <?php echo $Online?>
    You do realise that, that gets every user even if they're offline?

  13. #12
    Developer
    Rank
    Member +
    Join Date
    May 2008
    Posts
    482
    Liked
    201

    Re: Users Online SQL

    Quote Originally Posted by Jupos View Post
    You do realise that, that gets every user even if they're offline?
    yeah i see that i should not have use the rest of his code....

    the query is good though

    this is how im using it in modcms

    $online = $db->Execute("SELECT users_online,rooms_loaded FROM server_status");
    $registerd = $db->Execute("SELECT id FROM users");

    echo $online->fields['users_online']." User(s) Online | ";
    echo $online->fields['rooms_loaded']." Rooms(s) Loaded | ";
    echo $registerd->RecordCount()." Registered Users";

  14. #13
    MEHHREKHwhgfkehrkgthregir
    Rank
    Member +
    Join Date
    Sep 2011
    Location
    υηιтє∂
    Posts
    927
    Liked
    305

    Re: Users Online SQL

    Quote Originally Posted by leenster View Post
    yeah i see that i should not have use the rest of his code....

    the query is good though

    this is how im using it in modcms

    $online = $db->Execute("SELECT users_online,rooms_loaded FROM server_status");
    $registerd = $db->Execute("SELECT id FROM users");

    echo $online->fields['users_online']." User(s) Online | ";
    echo $online->fields['rooms_loaded']." Rooms(s) Loaded | ";
    echo $registerd->RecordCount()." Registered Users";
    Oh, I see what you have done.

    Basically you have called the $online variable to get the field 'user_online' ^^

  15. #14
    What you looking at?
    Rank
    Subscriber
    Join Date
    Oct 2009
    Location
    London
    Posts
    221
    Liked
    112

    Re: Users Online SQL

    Nice simple release.

    I personally use this.
    Code:
    <?php
    
    $host = 'localhost';
    $port = port;
    $user = 'root';
    $pass = 'pw';
    $db = 'dbname';
    
    mysql_connect("{$host}:{$port}", $user, $pass);
    mysql_select_db($db);
    
    print mysql_result(mysql_query("SELECT COUNT(*) FROM users users WHERE users.online = '1';"), 0);
    
    ?>
    All work's

  16. #15
    Release your Warhead!
    Rank
    Member +
    Join Date
    Sep 2011
    Posts
    1,173
    Liked
    134

    Re: Users Online SQL

    Nice, good for begs
    Posted via Mobile Device

 

 
Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •