Page 1 of 1

friend request

Posted: Wed Nov 03, 2010 8:27 pm
by birdmantk
Hi, I am strictly a beginner working on creating a social network for the simple reasons of learning a lot of vital things that PHP has to offer. I have created a friend request where the person requesting to be friends insert their id into the requested persons frid (friend request id) column. The column is coded to separate values by commas, I want to be able to run a check though to keep users from requesting a friend more than once.

At first I have created a mysql query that selects the values in the frid:

Code: Select all

SELECT frid FROM $table WHERE frid = '$dbid'
The $dbid is the users logged in session id.

I am thinking that there should probably be a while loop and then explode () array that compares the arrayed values while checking them with the requesting persons id to check for duplication. After that its pretty straight forward, running a if and else.

Re: friend request

Posted: Wed Nov 03, 2010 9:13 pm
by s.dot
Why not store a separate row in the table per request?

[text]id | from_id | to_id | accepted[/text]

Then, just check if a row exists.

Re: friend request

Posted: Wed Nov 03, 2010 9:14 pm
by s.dot
Moved to PHP code, because I'm not sure if you're going to go after a PHP solution using your setup or a new database table structure.