Php MYSQL

Started by Xatsker, 04-21-2010, 16:44:37

Previous topic - Next topic

Xatsker

s there a way to make this more random ?

$result = mysql_query('SELECT * FROM pictures ORDER BY RAND() LIMIT 1');
  •  


Nicpoint45

If your database is small,you should use RAND() otherwise try another solutions as like mentiones in the link that lukeg gave you
  •  


sam

Use this

$range_result = mysql_query( " SELECT MAX(`id`) AS max_id , MIN(`id`) AS min_id FROM `table` ");
$range_row = mysql_fetch_object( $range_result );
$random = mt_rand( $range_row->min_id , $range_row->max_id );
$result = mysql_query( " SELECT * FROM `table` WHERE `id` >= $random LIMIT 0,1 ");

anyquestion.webvertex.co.in

seoguro

thanks for sharing sam! you are good programmer.
  •