I cannot find solution of such problem. I need that $sql variable shows all values except the specified values as username != $var2 array values.
$user_data = user_data($session_user_id, 'user_id', 'username', 'blocked_emails');
$var = $user_data['blocked_emails'];
$var2 = explode(',', $var);
$sql = mysqli_query($con1, "SELECT * FROM `test` WHERE `username` != '$var2' ORDER BY user_id");
while ($row2 = mysqli_fetch_array($sql)) {
$uid = $row2['user_id'];
$username = $row2['username'];
}
NOT IN (…)instead of your!=.