[EMAIL PROTECTED] (Robb Kerr) writes:

> How's that for alliteration in a subject line?

Very nice! :-)

> [...]  And, if this is the best way to go, unfortunately I don't
> know how to write a random number generator in PHP so would
> appreciate any help.

Your idea sounds good, and luckily you don't have to build your own
random generator, behold:

  http://php.net/rand

Then call rand() with two arguments: the minimum and maximum ID, and
it will give you a random integer back between those two numbers.

You could also opt to have MySQL make the random number for you, and
then do a query like

  SELECT * FROM table ORDER BY RAND() LIMIT 1;

Then you wont have to deal with figuring out the number of rows in the
table as you would in the PHP case.  You can also increse the limit
to, say, 3 and then show three random quotes on your pages.  See

  http://dev.mysql.com/doc/mysql/en/Mathematical_functions.html#IDX1363

for a description of RAND() in MySQL.

-- 
Martin Geisler                                  My GnuPG Key: 0xF7F6B57B

PHP EXIF Library      |  PhpWeather              |  PhpShell
http://pel.sf.net/    |  http://phpweather.net/  |  http://gimpster.com/
Read/write EXIF data  |  Show current weather    |  A shell in a browser

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to