$new_random_string = substr(str_shuffle('0123456789'), 0, 2);
$strings = mysql_query("SELECT `string` FROM `table`");
while ($string = mysql_fetch_row($strings)) {
if ($new_random_string == $string[0])
// generate new random string
}
mysql_query("INSERT INTO `table` (`string`) VALUES ('".$new_random_string."')");
データベースにすでに存在する場合に備えて、ループで新しい文字列を生成したいと思います。ありがとう。