title: I get duplicate results with foreach
body: <p>I have this foreach so I want the visitagent value received for each element to check if it exists in the database, well then in block_viste_agent I have the function that blocks the visitagent value, the problem is that when I am going to block user via a value by checkbox then if there are others it adds them to me again there is also a detail that with characters like numbers I don't get them duplicates it work good, so I have the user agent and if I want to block a new one and there are 3 user agents already blocked, then it comes back and duplicates the ones that are blocked only what are blocked the user agent that I checkbox doesn't duplicates, what is wrong with my code?</p>
  
  <pre class="lang-php prettyprint-override"><code>foreach ($_POST['visitagent'] as $agent_id) {
      $checkagent = $wpdb-&gt;query(
          "SELECT * 
          FROM {$wpdb-&gt;prefix}lcl_user_agent
          WHERE user_agent = '$agent_id'"
      );
  
      if ($checkagent &lt;= 0) {
          $this-&gt;block_viste_agent(absint($agent_id), true);
      }
  }
  </code></pre>
  
  <p>I looked for this question but I don't know my code is diferrent
  <a href="https://stackoverflow.com/questions/25209631/getting-duplicated-results-in-foreach-loop">Getting duplicated results in foreach loop</a></p>