PHP implementation of Google Plus friends drag group effect _php instance

Source: Internet
Author: User
Tags php tutorial
Have you been looking for Google pls's buddy drag-and-drop grouping feature? Google is too handsome to implement! I've used PHP and jquery to implement the same buddy drag-and-drop app to add a group. This PHP tutorial will show you how to do this, and hopefully my sample can help you with your social networking projects.

The effect is as follows:

The sample database contains three tables, the relationship between the user and the user group.

User Table Members

The table contains member (user) data, such as Member_id,member_image.

User group groups

The relationship between user groups User_group

The relational table for user and user leases User_group contains user_id (memeber_id), group_id,member_id (), and sort (sort) fields.

JavaScript scripts

We use drag-and-drop on two class properties:. Members and. Group.

    

groups.php

We are here to handle drag-and-drop data processing capabilities for adding user groups.

<?php require_once ("multipleDiv.inc.php"); Initiate Object $obj = new Multiplediv (); ADD or Update Ajax call if (Isset ($_get[' m_id ')) and Isset ($_get[' g_id ')) {$obj->addmembers ((int) $_get[' m_id '), (i NT) $_get[' g_id '); Exit  }//Remove memebers from Groups Ajax call if (Isset ($_get[' do ')) {$obj->removemember ($_get[' mid ']); exit;}//Reload Groups each Ajax call if (Isset ($_get[' reload ')) {echo $obj->getmembers_reload (); exit;} if (Isset ($_get[' Reload_ Groups ']) {echo $obj->getmembergroups_reload (); exit;}//Initiate groups and Members $members = $obj->public_memb ERS (); $groups = $obj->groups ();?> Friends
 <?php if (!isset ($members)) $members = $obj->public_members (); if ($members) {foreach ($members as $member) {extract ($member); echo "\ n"; echo "\ n"; echo "". Ucwords ($member _name)."\ n "; echo "";}} else echo "members not available";?> Groups
 <?php if (!isset ($groups)) $groups = $obj->groups (); if ($groups) {foreach ($groups as $group) {extract ($group); echo "\ n"; Echo ucwords ($group _name); echo ""; echo ""; echo "
 
 
      \ n "; Echo $obj->updategroups ($group _id); echo"
"; } } ? >

multipleDiv.inc.php

Modify the database connection information here.

<?php//Database declaration ' s define ("SERVER", "localhost"); Define ("USER", "username"); Define ("PASSWORD", "PASSWORD"); Define ("DB", "Database");  

Here, we're done with the drag-and-drop grouping of friends on how to implement Google Plus. The above is the whole content of this article, I hope that everyone's learning has helped, but also hope that we support the script home.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.