[jQuery] What's wrong with this code? Update online.php

Results 1 to 9 of 9
  1. #1
    Zephyr Studios PRIZM is offline
    Grand MasterRank
    Feb 2012 Join Date
    DenmarkLocation
    2,291Posts

    [jQuery] What's wrong with this code? Update online.php

    Well, I have made a userbar at the top if my client, and I've added users online there.
    I found a script and edited it a little, to make it refresh my online.php every 50000 miliseconds.
    It doesn't seem to work, it still stands on 0 when I go into my client and the client is loaded.

    What's wrong with this code?
    <script data-javascript="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js" type="text/javascript"></script><script type="text/javascript">
    var auto_refresh = setInterval(
    function()
    {
    jQuery('#hi').fadeOut('fast').load('online.php').fadeIn("fast");
    }, 50000);
    </script>


    <div id="hi"><?php include("online.php"); ?></div>
    <font size="2"><div id="online" style="display: inline;">{online}</div> Jebba's online!</font>
    </div>
    Thanks!
    Last edited by PRIZM; 09-03-13 at 11:08 AM. Reason: nvm


  2. #2
    Zephyr Studios PRIZM is offline
    Grand MasterRank
    Feb 2012 Join Date
    DenmarkLocation
    2,291Posts

    Re: [jQuery] What's wrong with this code? Update online.php

    /bump

  3. #3
    Member Hyp is offline
    MemberRank
    Feb 2013 Join Date
    47Posts

    Re: [jQuery] What's wrong with this code? Update online.php

    Is this trying to show your people online & banner? if so I have a completely different code.

  4. #4
    Zephyr Studios PRIZM is offline
    Grand MasterRank
    Feb 2012 Join Date
    DenmarkLocation
    2,291Posts

    Re: [jQuery] What's wrong with this code? Update online.php

    Quote Originally Posted by Hyp View Post
    Is this trying to show your people online & banner? if so I have a completely different code.
    It shows how much peoples that's online in the client. I want the online number to update when a user join or leave.

  5. #5
    Web Developer Papercup is offline
    Grand MasterRank
    Nov 2009 Join Date
    WalesLocation
    1,607Posts

    Re: [jQuery] What's wrong with this code? Update online.php

    Make a script.js file and do

    PHP Code:
    $(document).ready(function() {
    $(
    '#hi').fadeOut('fast').load('online.php').fadeIn("fast");
    }, 
    500); 
    Never seen someone put $jQuery infront like that before.

  6. #6
    Zephyr Studios PRIZM is offline
    Grand MasterRank
    Feb 2012 Join Date
    DenmarkLocation
    2,291Posts

    Re: [jQuery] What's wrong with this code? Update online.php

    I've tried and tried and tried, nothing worx..

  7. #7
    Member Hyp is offline
    MemberRank
    Feb 2013 Join Date
    47Posts

    Re: [jQuery] What's wrong with this code? Update online.php

    Okay so, I found one, it updates the users AUTO, credits for this go to @Welfordian on twitter, (works with phoenix, IDK about other Emulators/databases)

    First, make a file in your root directory, then name it "online.php" or something, it doesn't matter. (Will need to be changed later if its not online.php)

    Then, paste this and save it (Make sure you edit 'DBPASS' and 'DBNAME'

    <?php$con = mysql_connect("localhost","root","DBPASS");
    Mysql_Select_db("DBNAME", $con);


    $q = mysql_query("SELECT * FROM server_status");
    while($row = mysql_fetch_assoc($q)){
    echo $row['users_online'];
    }
    ?>
    Then go to every page that has "online users" and make/add this:

    <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script><script type="text/javascript">
    function getUsers() { $.get('online.php', function(data) { $('.reload_users').html(data); }); setTimeout(getUsers, 1); } $(document).ready(function(){ getUsers(); });
    </script>
    Then where the "Online users" part is, change it to this:

    <span class="online_users"> <span class="reload_users"></span> User(s) Online!</span>
    Last edited by Hyp; 10-03-13 at 06:30 AM. Reason: Found it;)

  8. #8
    Zephyr Studios PRIZM is offline
    Grand MasterRank
    Feb 2012 Join Date
    DenmarkLocation
    2,291Posts

    Re: [jQuery] What's wrong with this code? Update online.php

    Quote Originally Posted by Hyp View Post
    Okay so, I found one, it updates the users AUTO, credits for this go to @Welfordian on twitter, (works with phoenix, IDK about other Emulators/databases)

    First, make a file in your root directory, then name it "online.php" or something, it doesn't matter. (Will need to be changed later if its not online.php)

    Then, paste this and save it (Make sure you edit 'DBPASS' and 'DBNAME'



    Then go to every page that has "online users" and make/add this:



    Then where the "Online users" part is, change it to this:
    It worked!
    Thanks dude!

  9. #9
    Member Hyp is offline
    MemberRank
    Feb 2013 Join Date
    47Posts

    Re: [jQuery] What's wrong with this code? Update online.php

    Quote Originally Posted by Prizm View Post
    It worked!
    Thanks dude!
    Your Welcome, Good to know I can help;)



Advertisement