$rowNum = -1; for($i = 0; $i < $threads; $i++) { $tmp = rand(0, mysql_num_rows($result2)); if($tmp == $rowNum); $threads--;