I am trying to pick out a random record from a table. I am using the build in RNG mt_rand() (I have also tried rand()) but keep getting the same 'random' number...

I know all about the inherent weaknesses of RNG functions, BUT, in more than 50 runs, I have gotten the same record each time, so clearly something is wrong.

This is the code I am using:

$sql = "SELECT tid FROM tips";
$result = mysql_query($sql);
$max = mysql_num_rows($result);

$seed = time();
mt_srand($seed);
$tid = mt_rand(2,$max); # get random number between 2 and max (inc)

$result = mysql_query("SELECT tip FROM tips WHERE tid=$tid");

Any ideas?

Christian