Multiple entries for one field

Hello All,

On my website, i want to make a option called follow for my users. But i dont know how i can store the name of persons for a particular user.
Suppose shail is a member. David , Katty, Queen viewed my profile and clicked on Follow Shail. Here i have increased the counter for Follow Shail. But how can i store the name of those persons in database, so that when they visit shail’s profile next time, they should see You are following Shail instead of Follow shail. Also, i want to display the list of members who are following Shail, if someone wants to see it.

Thanks
Shail

I don’t think this is a PHP question really, I would think that it is more a database question. In order to know who follows who you would need a table followers where you will store the id of the person followed on one field, and the id of the person that follows him on the other.

Another option, if you don’t want to use databases, is to use a text file per user and list the ids of the followers there.

Another option, if you don’t want to use databases, is to use a text file per user and list the ids of the followers there.

I can see some issues here with performance and file locking for a new programmer here

Shail,

You’ll want to do some reading on designing proper relational databases. You’ll want a simple, one to many relationship (one user to many followers). While a user is on someones profile, you would do an inner join on the user table and the followers table where user.id = the user your looking at, and the follower.id = the person who’s logged in. 1 Result would mean that person is following, 0 means that they are not.