title: php unique random number that is not in mysql table- check and then generate
body: <p>I have this script:</p>
  
  <pre><code>$rrezervim_id = rand(1, 5);
  $result = mysql_query("SELECT rrezervim_id FROM pax_list WHERE rrezervim_id='$rrezervim_id'");
  if(mysql_num_rows($result) == 1)
  {
  $rrezervim_id = rand(1, 5);
  } 
  else(mysql_num_rows($result) &gt; 1);
  {
    echo "$rrezervim_id";
  }
  </code></pre>
  
  <p>What i am trying to do is To generate a Unique Random number using PHP and MySql 
   i have the value inside table( rrezervim_id)[Values:1,2,3,5] so the only Random number that have to be generated and is free is Number 4.
  But with this script something is not working since i am getting even random that are already inserted in the table [Values:1,2,3,5].</p>
  
  <p>Any one can help me, is very important to make a check in mysql before generating the unique number if already exist in table.</p>