7 Jun
How to select database randomly
We can use mysql command for choose random from our table database.
PHP code :
$nilaisponsor = mysql_query( "SELECT * FROM reseller WHERE stat ='aktif' ORDER by rand() LIMIT 1 " ) or die( mysql_error() ); $datasponsor = mysql_fetch_array( $nilaisponsor );
That code will select random from table reseller where stat is aktif.
That’s simple.
This code can use for select and display banner randomly, or other used. Just remind, that
ORDER by rand() LIMIT 1
that’s for random selection. If you don’t use that code, select database will not randomly.
So, we must place at last our mysql command select,
ORDER by rand() LIMIT 1


