Need help - prepared statement - friendgroups

Need some help here!

I want to build a friendgroup - I have a full working friendsystem.

My ide is this. I got a list of friends, make a group named Test. Put selected friends in there, make another group and put another friends in there.

Some idees how to do that with prepared statements??

I search for tutorials, but couldn’t find any. Any suggestions?

The functions I need is this:

  1. Make group
  2. Add friend to group
  3. Show group with selected friends
  4. Rename groups
  5. Move friend from one group to another
  6. Delete group with all friends inside
  7. Delete a empty group
  8. Option to search for friends inside a group

Tutorial, free source code - everything would help to solve this mystery !

I just wrote this piece of code, and couldn’t get it to work:

public function create_friendgroup($profileownerid, $friends = NULL, $name)
{

$sql = "SELECT fg_friends_id FROM friend_groups WHERE fg_member_id = '$profileownerid' LIMIT 1";

	if($stmt = $this->conn->prepare($sql))
	{
		$stmt->execute();
		$stmt->bind_result($friend);
		$stmt->fetch();
		$stmt->close();

	}

if($friend != null)
	{
		$ua = explode(",", $friend);
		$ua = array_unique($ua);

		foreach ($ua as $u)
		{
		if($u !=NULL && $u !=$profileownerid)
		{
		$oldusers .= "{$u},";
	}	}
}

$newusers = $profileownerid;
if ($oldusers != null)
{
$newusers .= “,” . $oldusers;
}

$sql = “INSERT INTO friend_groups(fg_member_id,fg_friends_id, fg_name, fg_created_date) VALUES (?,?,?,?)”;

$date = date(“d-m-Y H:i”);

	if($stmt = $this->conn->prepare($sql))
	{
		$stmt->bind_param('iiss',$profileownerid,$friends = trim($newusers, ","), $name,$date);
		$stmt->execute();
		$stmt->close();
   }

}

K.F

Problem solved! I figured it all out tonight :slight_smile:

Sponsor our Newsletter | Privacy Policy | Terms of Service