Notification system for user groups

Hi, I’m working on a event manager and I would like to create a notification system for a group of users.
When an admin creates a new event then php create a notification inside mysql with status 0 if not read and then it changes to status 1 if read.
I’m using the group id instead of the user id, and the problem is when the first user click on the notification it updates the notification status so other user are not viewing the notification. How can I create multiple entries in the database using the group id? Maybe if I can create a row for each user into the database I can solve this problem.

This is my php code

session_start();

include('../../../config/database.php');
include('../../../includes/functions.php');

$event_title = $_POST['titleevent'];
$event_color = $_POST['eventcolor'];
$event_start = $_POST['startevent'];
$new_start_date = date('Y-m-d 00:00:00', strtotime($event_start));
$event_end = $_POST['endevent'];
$new_end_date = date('Y-m-d 23:59:00', strtotime($event_end));
$event_group = $_POST['usergroup'];
$event_description = $_POST['eventdescription'];

	if ($create_event = mysqli_prepare($conn, "INSERT INTO user_events (event_title, event_description, event_start, event_end, event_color, event_group)
	                VALUES (?, ?, ?, ?, ?, ?)" )) {

	mysqli_stmt_bind_param($create_event, 'sssssi', $event_title, $event_description, $new_start_date, $new_end_date, $event_color, $event_group);
	mysqli_stmt_execute($create_event);
	
		// get event id
		$event_id = mysqli_insert_id($conn);

		$event_start_date = date('d-m-Y', strtotime($new_start_date));
        $notification = "Nuovo evento <span class='text-warning'><strong>$event_title</strong></span> inizia il $event_start_date";
        $notification_status = "0";
        $notification_category= "events";

        $event_notification = mysqli_prepare($conn, "INSERT INTO event_notifications (e_notification_sent_by, e_notification_sent_to, e_notification_message, e_notification_time, e_notification_status, e_notification_category, e_notification_category_id) VALUES(?,?,?,now(),?,?,?)");
        mysqli_stmt_bind_param($event_notification, 'iisisi', $userid, $event_group, $notification, $notification_status, $notification_category, $event_id);
        mysqli_stmt_execute($event_notification);
        mysqli_stmt_close($event_notification);
     
	
	$_SESSION['success_msg'] = 'Event created!';
	header("location: ../../admin_calendar_app/admin_calendar.php");
	exit();

	mysqli_stmt_close($create_event);


	}else{

		echo "Ops, error";

	}

Many thanks for you help

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.