Never been to DZone Snippets before?

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

About this user

Ricardo m. García

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS 

PHP : Filas al azar / Random Rows

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;
	}
}

PHP : Conectar con Access / Connect with Access

Conectar con Access / Connect with Access.
Código fuente / Source code :

$pathDB = str_replace("/", "\\", $_SERVER["DOCUMENT_ROOT"]) . "\\directory1\\directory2\\bdd.mdb";

if(!file_exists($pathDB))
{
echo "!!! Base de datos no encontrada ".$pathDB;
exit;
}

$conexion = odbc_connect("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=".$pathDB, "ADODB.Connection", "", "SQL_CUR_USE_ODBC");
$sql="select * from tabla where 1";
$resultado=odbc_exec($conexion,$sql);
if($resultado)
{
	while($fila=odbc_fetch_array($resultado))
	{
	echo $fila['campo1']."<br />";
	echo $fila['campo2']."<br />";
	}
odbc_close_all();
}
« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS