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:
- Make group
- Add friend to group
- Show group with selected friends
- Rename groups
- Move friend from one group to another
- Delete group with all friends inside
- Delete a empty group
- 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