I am currently coding something which allows users to create an announcement in their group. My idea is that the announcement will be shown on the group page for each member and they can click the cross to remove the announcement.
For this, I'm using db tables to insert a record for each userid with the same message and then when they delete the announcement it removes the record from the database.
Now, I have a query which gets me all the user ID's I want but i'm struggling on finding out how to insert multiple records, the code below is what I have so far but it's only inserting 1 record (the first userid from the query which gets the IDs):-
I think I may need a foreach statement but not sure how to implement it?
Thanks in advance
//Get the User ID's
$query='SELECT cm.member_id FROM members AS cm WHERE cm.group_id = '.$id.' AND cm.name NOT IN ("'.$username.'") AND cm.deleted = 0';
//Insert a record for each member so they can dismiss the record
$query='INSERT INTO announcements (group_id,member_id,subject,description,added_by,date_added)