michaelsanford
Translator, Web Developer
On the main page of my new web site, it will display a random passage of text (lyrics) pulled from a MySQL database.
Now, do I really need to go through the extra code of srand();ing that random number, or not? It's not cryptography...
Also, how is rand() seeded if srand() isn't called?
I currently have two records in the database, and I echoed $rand_lyric_id and got '1 2 2 2 1 1 2 1 2 1 1' so it looks random enough...
PHP:
$result_count = mysql_query("SELECT COUNT(lyric_id) FROM lyrics", $link);
$resultRow = mysql_fetch_array($result_count);
$rand_lyric_id = rand(1, $resultRow['0']);
Now, do I really need to go through the extra code of srand();ing that random number, or not? It's not cryptography...
Also, how is rand() seeded if srand() isn't called?
I currently have two records in the database, and I echoed $rand_lyric_id and got '1 2 2 2 1 1 2 1 2 1 1' so it looks random enough...