Click here to Skip to main content
15,890,282 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have created a website in which we can add friends..
i want user can see his online friends how to do this...

database table of friends..
CREATE TABLE [dbo].[tbl_friendmaster](
	[i_autoid] [int] IDENTITY(1,1) NOT NULL,
	[Friendgroup] [varchar](50) NOT NULL,
	[Message] [varchar](500) NOT NULL,
	[i_Friendid] [int] NOT NULL,
	[i_myid] [int] NOT NULL,
	[approvalstatus] [int] NOT NULL,
	[CreateDate] [datetime] default getdate()  NOT NULL
)
Posted

As per my understanding, you have to maintain Logged-In user information into database. Follow below steps:

1. Whenever any user logged-in then insert info into database. So when user logged-in then mean user is online and when logged-out mean user is offline.
Note: But you have to do analysis on time expire. Suppose user is not logged-out and closed his browser then how you will identify whether user is logged-out (offline).

2. Call periodically to database in 10 or 15 second and based on info set status in your friend list

Thanks
 
Share this answer
 
Comments
se.nishant 22-Apr-11 3:10am    
thanks this helps me .
Your question is not very clear on all the naming conventions used and if any other details are there. Assuming this is the only table to store data and following naming convention means:
i_autoid = just an id  (No idea why you have it... not needed!)
i_Friendid = id of the friend of logged in user
i_myid = id of the logged in person


Try:
SQL
SELECT
  i_Friendid
FROM
  tbl_friendmaster
WHERE
  i_myid = @loggedInUserId

Now, above query gives all the friendid that are related to logged in user. Now, someone being online or offline must be tracked other way (and not through this table). You need to use the tracking online user with the query result to get only online friends.

Try!
 
Share this answer
 
Comments
Sandeep Mewara 22-Apr-11 3:15am    
And the downvote was for? Any comments please... I would love to know. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900