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.