Seo Forum & AI

Coding & Programming => Programming Forum => PHP Forum => Topic started by: Xatsker on 04-21-2010, 17:44:37

Title: Php MYSQL
Post by: Xatsker on 04-21-2010, 17:44:37
s there a way to make this more random ?

$result = mysql_query('SELECT * FROM pictures ORDER BY RAND() LIMIT 1');
Title: Re: Php MYSQL
Post by: Nicpoint45 on 04-21-2010, 17:45:22
If your database is small,you should use RAND() otherwise try another solutions as like mentiones in the link that lukeg gave you
Title: Re: Php MYSQL
Post by: sam on 02-08-2012, 01:37:30
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 (http://anyquestion.webvertex.co.in)
Title: Re: Php MYSQL
Post by: seoguro on 02-17-2012, 06:06:57
thanks for sharing sam! you are good programmer.