title: php check if number exists in database
body: <p>basically i dont want duplicate number in certain field. how do i do that?</p>
  
  <pre><code>table user:
  id   name    group
  1    a        2
  2    b        3
  3    c        1
  4    d        6
  5    e        5
  
  $q = $db-&gt;query("SELECT COUNT(t_group) FROM user");
  $r = $q-&gt;fetch_row;
  if($r[0] &gt; 0) :
       $rand_no = rand(1,10);
       $db-&gt;query("INSERT INTO user(name, group) VALUES('$name','$rand_no')");
  endif;
  </code></pre>