I have a calendar application where users can submit calendar events(day, night, unavailable to the title column of my DB) for selected dates. More like an availability booking. I have a database table called events with id, username, name, title, date and status columns(all status =1). This function below outputs all event inputs by all users on the dates but i want to be able to output only data for the $_SESSION user. Thanks
function getEvents(date){
                $.ajax({
                    type:'POST',
                    url:'functions.php',
                    data:'func=getEvents&date='+date,
                    success:function(html){
                        $('#event_list').html(html);
                    }
                });
    
                // Add date to event form
                $('#event_date').val(date);
            } 
 function getEvents($date = ''){
            $date = $date?$date:date("Y-m-d");
        
            $eventListHTML = '<h2 class="sidebar__heading">'.date("l", strtotime($date)).'<br>'.date("F d", strtotime($date)).'</h2>';
        
            // Fetch events based on the specific date
            global $db;
              $stmt = $db->prepare("SELECT * FROM events WHERE date = ? AND username = ?");
    $stmt->bind_param("ss", $date, $username);
    $stmt->execute();
    $result = $stmt->get_result();
            if($result->num_rows > 0){
                $eventListHTML .= '<ul class="sidebar__list">';
                $eventListHTML .= '<li class="sidebar__list-item sidebar__list-item--complete">Availability</li>';
                $i=0;
                while($row = $result->fetch_assoc()){ $i++;
                    $eventListHTML .= '<li class="sidebar__list-item"><span class="list-item__time">'.$i.'.</span>'.$row['title'].'</li>';
                }
                $eventListHTML .= '</ul>';
            }
            echo $eventListHTML;
        }
