Page 1 of 1

How Can I Add On My Site ?

Posted: Mon Dec 12, 2005 2:26 pm
by saqib389
Hello every one
is there any way that when my site loads these information comes that how much

Members: 47,077
Visitors Online: 1,392
Members Online: 10
Visits: 1,229,681
Members Online:
abc
def
ghi
ijk
lmn
opq


Like This.......


Waiting for hopefull response
SaQib

Posted: Mon Dec 12, 2005 2:27 pm
by HiddenS3crets
yes, but it's not that simple. You'll need log files or a table to hold this kind of data, then use SQL queries to gather the data to be displayed.

Posted: Mon Dec 12, 2005 2:31 pm
by Chris Corbyn
Yes.

You need to store your member information in a database. Then you can see how many members you have very easily using

Code: Select all

select count(*) from members
The hit counter can also be done with a database or very simply using a flat file (there's a recent snippet in our code snippets forum for the latter).

The visitors online... well that need to use a database where you update a timestamp for each user on each link click and then

Code: Select all

$query = "select count(*) from user_activity where timestamp > ".(time()-(5*60));
;)

These things can all individually be looked up on these forums pretty quickly by searching :)

Posted: Mon Dec 12, 2005 2:37 pm
by shiznatix
ok lets see. total members would not be hard. just

Code: Select all

select count(*) as members from members_table
and that will give you total number of members.

the other "how many people are online" is a bit tricky. now if you want "guests" on the site and not "guests + members" that may be harder, but just doing the guests+members online (total number) would be discussed here
http://webmonkey.wired.com/webmonkey/04/50/index4a.html

members online, what i would do is have a seperate table where you store the username and the last time the user was visited any page, and MAYBE the page the user visited. then to find out how many users where online i would just select from that table where the last page hit time was 5 minutes or less than the current time. make sure you run a query on each page if the user is logged in to update the db with the new time that the user hit a site. to get the number of members just do a mysql_num_rows() then the members online just display the usernames from the table.


if you need more help, just post

EDIT: JESUS! EVERY TIME I GET BEAT!

Posted: Mon Dec 12, 2005 3:16 pm
by saqib389
well i m new in php.. so i m not getting all of urz point

if u ppl can refer me any good tutorials.. from where i can get that thing. so tat would b more clear for me.....

thnx in advance

d11wtq | You'd probably get better responses if you used correct grammar -- AOLSpeak is hard to read

Posted: Mon Dec 12, 2005 3:45 pm
by foobar
saqib389 wrote:well i m new in php.. so i m not getting all of urz point

if u ppl can refer me any good tutorials.. from where i can get that thing. so tat would b more clear for me.....

thnx in advance
Well, you should definitely check out the PHP Manual. It's a great start and even better reference.

Here's some good links from these forums:

viewtopic.php?t=29816

viewtopic.php?t=21400