friend request

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
birdmantk
Forum Newbie
Posts: 1
Joined: Wed Nov 03, 2010 8:08 pm

friend request

Post 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.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: friend request

Post 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.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: friend request

Post 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.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply