I wrote the following code to avoid duplicate ID, but I can not get out of the for loop.
print $someid;
is Keep displaying 0.
<?php
for (; ; ) {
$sql = "SELECT COUNT * FROM user WHERE id = :id";
$id = sha1(uniqid(mt_rand(), true));
$idcheck = $connect -> prepare($sql);
$idcheck->bindParam(':id', $id, PDO::PARAM_STR);
$idcheck -> execute();
$someid = $idcheck -> rowCount();
print $someid;
if ($someid = 0) {
break;
}
}
?>
How can I get out of the loop only if there are no duplicates?