I want to select a random userid
from this query where level = 1 (Normal user) and alive = Yes (User is alive and can play)
$getaid = $sql->query("SELECT userid FROM `users` WHERE `level`='1' AND `alive`='yes'");
I know I can use
$totalusers = mysql_num_rows($getaid);
$randomuserid = rand(1,$totalusers);
to select a random userid but in that code there's a chance that it select a user that is dead (alive = No) or a staff member (level >= 1). is there a better way I can select a random userid without a chance to grab staff members/dead members?
Aucun commentaire:
Enregistrer un commentaire