I have a foreach while loop to search every sent chat message, and it will display if it gets a match.
My issue is that it displays multiple of the same result.
Result:
<?php
    $bad_word = array("badword","bad_word","bad","frick","heck");
    foreach($bad_word as $word){
        $get_flags = $con->query("SELECT DISTINCT username,msg,date_log,time_log FROM chat_logs WHERE msg LIKE '%$word%'");
        while($bad_msg = mysqli_fetch_array($get_flags)){
            echo '
            <div class="msg">
            <div class="msg-top">
            <p><b>'.$bad_msg['username'].'</b> '.$bad_msg['date_log'].' - '.$bad_msg['time_log'].'</p></div>';
            if(!empty($bad_msg['msg'])){
                echo '<span>'.$bad_msg['msg'].'</span>';
            }
            echo '</div>';
        }
    }
?>
I am expecting unique results from my query, but im still getting duplicate results.

 
    