How can you prevent receiving multiple emails for each query result in PHP?

Issue: To prevent receiving multiple emails for each query result in PHP, you can use a flag variable to track if an email has already been sent for a particular query result. This way, you can ensure that each query result only triggers one email notification.

// Example PHP code to prevent multiple emails for each query result

// Initialize flag variable
$emailSent = false;

// Perform query
$queryResult = // Your query code here;

// Check if query result meets conditions to send email
if ($queryResult && !$emailSent) {
    // Send email code here

    // Set flag variable to true to indicate email has been sent
    $emailSent = true;
}