Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Mar 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need help!! Prepared statement and friend group

    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 !

    K.F

  • #2
    Regular Coder cyrus709's Avatar
    Join Date
    Dec 2008
    Posts
    102
    Thanks
    22
    Thanked 5 Times in 5 Posts
    Here is a tutorial for php http://www.w3schools.com/php/

    Well what you will need is to look at http://www.w3schools.com/.
    Essentially what you will need to do is create a database.
    and a table with the columns being set as the information you want to insert.

    Then create a form with html that runs a php code when submitted that will update your table accordingly.

    NOTE: do not name your DB, Table, or Columns "group"
    Last night I lay in bed looking up at the stars in the sky and I thought to myself, where the heck is the ceiling.

  • #3
    New to the CF scene
    Join Date
    Mar 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, I know the basic stuff


    I build the site from scratch, and I have made a fullyworking friend system and private messaging system.

    The problem is with preparted statement it do not handle arrays the normal way.

    If I now make a friendgroup - as I also did - it will put names and name on group in same table, like this


    ID 34 ID 45 GRPNAME
    ID 34 ID 23 GRPNAME

    A lot of mess come out of that

    Here is the code for my last try -> This is not the code that are working btw. It's the code with the array problem!



    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();
    }
    }
    Last edited by KFlash32; 03-27-2011 at 07:28 PM.

  • #4
    New to the CF scene
    Join Date
    Mar 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I figured it all tonight! It was not the prepared statement that was wrong.
    Some bugs in JQuery / AJAX calls


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •