Jump to content

Nees some help with prepared statement and friend group system


KFlash32

Recommended Posts

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 !

 

So far is this the code I made, and didn't work at all

 

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.