DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

PHP : Filas Al Azar / Random Rows

10.19.2007
| 4837 views |
  • submit to reddit
        Filas al azar / Random Rows

function dame_unas_filas_al_azar($tabla,$numero_de_filas)
{
$sql="SELECT * FROM ".$tabla." ORDER BY RAND(NOW()) LIMIT ".$numero_de_filas;
$resultado = mysql_query($sql);
	if($resultado)
	{
	return mysql_fetch_array($resultado);
	}
	else
	{
	return false;
	}
}