4WebHelp
 FAQ  •  Search  •  User Groups  •  Forum Admins  •  Smilies List  •  Statistics  •  Rules   •  Login   •  Register
Toggle Navigation Menu

 Text counter..
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic
Author Message
Mad
Junior WebHelper
Junior WebHelper


Joined: 20 Feb 2003
Posts: 18
Location: England

PostPosted: Thu Feb 20, 2003 11:34 am (21 years, 2 months ago) Reply with QuoteBack to Top

I need a counter that will count, the users viewing my site currently, and the maximum amount of users on my site at one time, any suggestions?

I have PHP and MySQL access.
Thanks Smile

________________________________
www.celldamage.org
OfflineView User's ProfileFind all posts by MadSend Personal MessageVisit Poster's WebsiteAOL Instant Messenger
adam
Forum Moderator & Developer



Joined: 26 Jul 2002
Posts: 704
Location: UK

PostPosted: Thu Feb 20, 2003 5:48 pm (21 years, 2 months ago) Reply with QuoteBack to Top

you could always find the relevant bit of code in a forum and somehow work that into your site...seems like a complicated thing to try to write from scratch Very Happy

________________________________
It's turtles all the way down...
OfflineView User's ProfileFind all posts by adamSend Personal MessageVisit Poster's Website
Mad
Junior WebHelper
Junior WebHelper


Joined: 20 Feb 2003
Posts: 18
Location: England

PostPosted: Fri Feb 21, 2003 10:09 am (21 years, 2 months ago) Reply with QuoteBack to Top

i don't have any experience with forums to do that, if anyone could find me such a code it would be very helpful Very Happy

________________________________
www.celldamage.org
OfflineView User's ProfileFind all posts by MadSend Personal MessageVisit Poster's WebsiteAOL Instant Messenger
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Sat Feb 22, 2003 9:17 am (21 years, 1 month ago) Reply with QuoteBack to Top

Here are a few interesting links:

http://codewalkers.com/seecode/75.html
http://www.devarticles.com/art/1/122/3
http://php.inc.ru/main.php?view=tutorials&t=p_active

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
Mad
Junior WebHelper
Junior WebHelper


Joined: 20 Feb 2003
Posts: 18
Location: England

PostPosted: Sat Feb 22, 2003 11:10 am (21 years, 1 month ago) Reply with QuoteBack to Top

wow, thanks!! Very Happy

________________________________
www.celldamage.org
OfflineView User's ProfileFind all posts by MadSend Personal MessageVisit Poster's WebsiteAOL Instant Messenger
Ben
Senior WebHelper
Senior WebHelper


Joined: 08 Jan 2002
Posts: 431
Location: Liverpool - UK

PostPosted: Sat Feb 22, 2003 7:46 pm (21 years, 1 month ago) Reply with QuoteBack to Top

http://www.gtchat.de/download_misc_en.html

Example @ http://www.gtchat.de/main_en.html

________________________________
Ben Scott

Red and White Kop
OfflineView User's ProfileFind all posts by BenSend Personal MessageSend emailVisit Poster's Website
Mad
Junior WebHelper
Junior WebHelper


Joined: 20 Feb 2003
Posts: 18
Location: England

PostPosted: Wed Feb 26, 2003 8:21 pm (21 years, 1 month ago) Reply with QuoteBack to Top

has anyone found a way to make a 'most online users' thing yet?

thanks for those guys!!

________________________________
www.celldamage.org
OfflineView User's ProfileFind all posts by MadSend Personal MessageVisit Poster's WebsiteAOL Instant Messenger
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Wed Feb 26, 2003 8:30 pm (21 years, 1 month ago) Reply with QuoteBack to Top

What is wrong with the links provided above? Do you mean that you require the "most users online" thing as well as "x users online"?

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
Mad
Junior WebHelper
Junior WebHelper


Joined: 20 Feb 2003
Posts: 18
Location: England

PostPosted: Wed Feb 26, 2003 8:32 pm (21 years, 1 month ago) Reply with QuoteBack to Top

The links above are very helpful and i have used them and found a script i needed Smile

But i could also do with a most online users too, i understand i'm nagging you Sad

________________________________
www.celldamage.org
OfflineView User's ProfileFind all posts by MadSend Personal MessageVisit Poster's WebsiteAOL Instant Messenger
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Wed Feb 26, 2003 8:36 pm (21 years, 1 month ago) Reply with QuoteBack to Top

Which one did you use? We can't help you unless we know which one you chose Smile

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
Mad
Junior WebHelper
Junior WebHelper


Joined: 20 Feb 2003
Posts: 18
Location: England

PostPosted: Sun Mar 02, 2003 5:32 pm (21 years, 1 month ago) Reply with QuoteBack to Top

I used this code :

Code:
<?php
$server = "localhost";
$db_user = "...";
$db_pass = "...";
$database = "...";

$db = mysql_connect($server, $db_user,$db_pass);
mysql_select_db($database,$db);

$timeoutseconds = 900; //5 minutes

$timestamp = time();
$timeout = $timestamp-$timeoutseconds;

$insert = mysql_query("INSERT INTO useronline VALUES ('$timestamp','$REMOTE_ADDR','$PHP_SELF')",$db);
if(!($insert)) {
print "Useronline Insert Failed > ";
}
$delete = mysql_query("DELETE FROM useronline WHERE timestamp<$timeout",$db);
if(!($delete)) {
print "Useronline Delete Failed > ";
}
$result = mysql_query("SELECT DISTINCT ip FROM useronline WHERE file='$PHP_SELF'",$db);
if(!($result)) {
print "Useronline Select Error > ";
}
$user = mysql_num_rows($result);


mysql_close();
if($user == 1) {
print("<font class=userinfotitle>Users online:</font><font class=userinfotext> $user\n</font>");
} else {
print("<font class=userinfotitle>Users online:</font><font class=userinfotext> $user\n</font>");
}
?>

Smile

________________________________
www.celldamage.org
OfflineView User's ProfileFind all posts by MadSend Personal MessageVisit Poster's WebsiteAOL Instant Messenger
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Sun Mar 02, 2003 5:49 pm (21 years, 1 month ago) Reply with QuoteBack to Top

OK, you should now create a table like this:

Code:
CREATE TABLE config (
    config_name varchar(255) NOT NULL,
    config_value varchar(255) NOT NULL,
    PRIMARY KEY (config_name)
);


Then add some code to this effect:

Code:
$most_online = mysql_query("SELECT config_value FROM config WHERE config_name = 'most_online'",$db);

while ($row = mysql_fetch_array($most_online, MYSQL_ASSOC)) {
    $row['config_value']=$most_online2;
}

if ($user>$most_online2) {
$update_online = mysql_query("UPDATE config SET config_value = $user WHERE config_name = 'most_online'",$db);
}


There's probably something wrong with this code, but the idea's there Very Happy

You'll have to add a row into the config table with:
config_name='most_online' and config_value=0.

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
Mad
Junior WebHelper
Junior WebHelper


Joined: 20 Feb 2003
Posts: 18
Location: England

PostPosted: Sun Mar 02, 2003 8:12 pm (21 years, 1 month ago) Reply with QuoteBack to Top

should i put that table in a new database or just add to the one i have?

________________________________
www.celldamage.org
OfflineView User's ProfileFind all posts by MadSend Personal MessageVisit Poster's WebsiteAOL Instant Messenger
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Mon Mar 03, 2003 7:07 am (21 years, 1 month ago) Reply with QuoteBack to Top

Add it to the one you have. Smile

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
Mad
Junior WebHelper
Junior WebHelper


Joined: 20 Feb 2003
Posts: 18
Location: England

PostPosted: Mon Mar 03, 2003 5:39 pm (21 years, 1 month ago) Reply with QuoteBack to Top

Thanks!

________________________________
www.celldamage.org
OfflineView User's ProfileFind all posts by MadSend Personal MessageVisit Poster's WebsiteAOL Instant Messenger
Display posts from previous:      
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic


 Jump to:   


Go to page 1, 2  Next

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.


Page generation time: 0.297164 seconds :: 18 queries executed :: All Times are GMT
Powered by phpBB 2.0 © 2001, 2002 phpBB Group :: Based on an FI Theme