How Can I Add On My Site ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
saqib389
Forum Commoner
Posts: 44
Joined: Wed Nov 30, 2005 2:13 am

How Can I Add On My Site ?

Post 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
HiddenS3crets
Forum Contributor
Posts: 119
Joined: Fri Apr 22, 2005 12:23 pm
Location: USA

Post 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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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 :)
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post 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!
saqib389
Forum Commoner
Posts: 44
Joined: Wed Nov 30, 2005 2:13 am

Post 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
foobar
Forum Regular
Posts: 613
Joined: Wed Sep 28, 2005 10:08 am

Post 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
Post Reply