//_Semicolon;

Will code for food; The ramblings of Talifhani Luvhengo;

Selecting random row from mysql

Selecting a random row from mysql the easy way

$query = "select * from tableName order by rand() limit 1";
$resultSet = mysql_query($query);
$randomRow = mysql_fetch_row($result_set);

Selecting multiple random rows is as easy as changing the limit, say i
wanted 10 random rows, the code would look like this:

$query = "select * from tableName order by rand() limit 10";
$resultSet = mysql_query($query);
$randomRow = mysql_fetch_row($result_set);
Get Adobe Flash player

Page optimized by WP Minify WordPress Plugin