I want to delete several members as groups, if the statement successfully conveys to many members from one group, but Deletion (ifelse) only removes a member!
if (isset ($ _POST ['add_member'])) {$ group_id = $ _POST ['group_id']; Foreign Currency ($ _POST ['member_id'] as a $ member) {$ query = "Selection ID from member group WHERE member_id = $ member and` group_id` = $ group_id [0] "; If (! Mysqli_num_rows (mysqli_query ($ connection, $ query))) {$ query = "Include member member group (member_id, group_id) value ($ member, $ group_id [0])"; Mysqli_query ($ connection, $ query) or die (mysqli_errno ($ connection)); } Echo "& lt; div class = 'alert alert-info' & gt; member assigned. & Lt; / div & gt;"; }} Otherwise (isset ($ _POST ['remove_member'])) {$ member_id = $ _POST ['member_id']; Foreign currency ($ _POST ['group_id'] as $ group) {$ query = "Delete from group member WHERE group_id = $ group and` member_id` = $ member_id [0] "; $ Line = mysqli_query ($ connection, query $);
Thanks!
If you want to remove all members from that group
$ query = "Delete from group member WHERE group_id = $ group";
Or if you want to delete the selected members, you must remove each member from your post such as
$ member_arr = explode (',' , $ _POST ['member_id']); Foreign currency (member $ member $ as member) {$ query = "member_ delete group WHERE" member_id` = $ member "; }
If you have been mentioned in the comment in $ member_id [0]
, then you can query your query with IN
You can write such as
$ query = "member_distance to group, where member_id` (". $ $ Member_id [0]. ")";
Keeping in mind that $ member_id [0]
is 1,2,3,4,5,6
. If it is in the array
format, then you must use IMPLODE
as
$ query = "member_graha" in member_id` ".implode (',', $ member_id [0]).");
Comments
Post a Comment