Jump to content
xisto Community
snlildude87

Users Online Script In Php how do i get one?

Recommended Posts

I've been seeing a whole bunch of sites that have a Statistics corner, and in there, there are things that says "Users Online:", "Page Loads:", "Unique Hits:", and "IP:". Well, I was wondering, where do these users get one of these nifty things?I know that PHPNuke offers one, but most of the sites that I go to do not use PHPNuke.Any reply is appreciated. :rolleyes:

Share this post


Link to post
Share on other sites

Well, I know exactly what you mean...and here will be my attempt..
im going to the point right away btw..

Ow and im assuming you got a config.php and know your mysqltables..
Dont wanna go all over that line again :rolleyes:

For one, you need to alter or create a new table that has user_active field, this field contains TIMESTAMP and you are to make a line to update this field once a user logs in..like:

session_start();$user=$_SESSION['user'];$time=date("F j, Y, g:i a");$active=mysql_query("update usertable set user_active='$time' where username='$user'");

anyway..
It requires alot of coding from what i know and i dont have that much time right now, so heres the "first part" (sorry =/)
<?php//latest registered user..{     $sql = "SELECT username FROM usertable WHERE username='' ORDER BY user_id DESC LIMIT 1";    list($lastuser) = $db->sql_fetchrow($db->sql_query($sql));    return $lastuser;}//total users{    $sql = "SELECT COUNT(*) FROM usertable WHERE user_id > 1";    list($numrows) = $db->sql_fetchrow($db->sql_query($sql));    return $numrows;}{    $sql = "SELECT COUNT(*) FROM usertable WHERE user_regdate='".date("M d, Y")."'";    list($userCount[0]) = $db->sql_fetchrow($db->sql_query($sql));    $sql = "SELECT COUNT(*) FROM usertable WHERE user_regdate='".date("M d, Y", time()-86400)."'";    list($userCount[1]) = $db->sql_fetchrow($db->sql_query($sql));    return $userCount;}

Hope this gives you a small step forward..you know im not a pro at this hehe :lol:

Share this post


Link to post
Share on other sites

Well, I know exactly what you mean...and here will be my attempt..

im going to the point right away btw..

 

Ow and im assuming you got a config.php and know your mysqltables..

Dont wanna go all over that line again :rolleyes:

 

For one, you need to alter or create a new table that has user_active field, this field contains TIMESTAMP and you are to make a line to update this field once a user logs in..like:

session_start();$user=$_SESSION['user'];$time=date("F j, Y, g:i a");$active=mysql_query("update usertable set user_active='$time' where username='$user'");

anyway..

It requires alot of coding from what i know and i dont have that much time right now, so heres the "first part" (sorry =/)

<?php//latest registered user..{     $sql = "SELECT username FROM usertable WHERE username='' ORDER BY user_id DESC LIMIT 1";    list($lastuser) = $db->sql_fetchrow($db->sql_query($sql));    return $lastuser;}//total users{    $sql = "SELECT COUNT(*) FROM usertable WHERE user_id > 1";    list($numrows) = $db->sql_fetchrow($db->sql_query($sql));    return $numrows;}{    $sql = "SELECT COUNT(*) FROM usertable WHERE user_regdate='".date("M d, Y")."'";    list($userCount[0]) = $db->sql_fetchrow($db->sql_query($sql));    $sql = "SELECT COUNT(*) FROM usertable WHERE user_regdate='".date("M d, Y", time()-86400)."'";    list($userCount[1]) = $db->sql_fetchrow($db->sql_query($sql));    return $userCount;}

Hope this gives you a small step forward..you know im not a pro at this hehe :lol:

144983[/snapback]

Where did you learn that? I thought I have mastered MySQL, now, I'm not familiar with SELECT COUNT(*) and using greater than and less than... How can I master MySQL?

Share this post


Link to post
Share on other sites

google is your friend.when i look fora specific statement, such as counting table inserts, i search google and i so far always found my answer :rolleyes:i have not mastered mysql nor any other language of programming, but i do learn alot from making scripts that need new statements, learn through practise :lol:

Share this post


Link to post
Share on other sites

google is your friend.

 

when i look fora specific statement, such as counting table inserts, i search google and i so far always found my answer :rolleyes:

 

i have not mastered mysql nor any other language of programming, but i do learn alot from making scripts that need new statements, learn through practise :lol:

145654[/snapback]

Can you give me a good MySQL tutorial site that teaches something like that SELECT COUNT(*) and other MySQL hidden functions that i haven't learned yet.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.