Started typing and then some stupid script crashed the browser...
Okay, I started thinking along Unipus' line of thinking, which would work. If you may end up having scores or users and don't want a large query, you could also do something like
Code: Select all
$count_result = mysql_query("SELECT COUNT(users.uid) FROM users, stats WHERE users.uid=stats.uid");
$random_number = rand(0, mysql_result($count_result, 0) - 1);
$random_user_result = mysql_query("SELECT users.gender AS 'gender',stats.dob AS 'dob',stats.sex_pref AS 'sex_pref',stats.mar_stat AS 'mar_stat',stats.country AS 'country' FROM users, stats WHERE users.uid=stats.ui LIMIT $random_number, 1");
Or something like that. That way it should work just fine even if you end up with half a million users. Don't remember if MySQL < 4 allows you to use "LIMIT a, b" but if not, just use "START AT a LIMIT b" instead and it should keep MySQL happy. Unipus' method would work fine, I just can't help but think of scalability.
