Foros del Web » Programando para Internet » PHP »

Recorrer un mysql_fecth_array

Estas en el tema de Recorrer un mysql_fecth_array en el foro de PHP en Foros del Web. Buenas, estoy intentando recorrer una consulta sql que tiene 3 filas como resultado $sqlnombres="SELECT nombre FROM `cliente` ORDER BY nombre"; $nombres=generaSQL($sqlnombres,$conexion); //aki me devuelve el ...
  #1 (permalink)  
Antiguo 09/11/2007, 12:21
 
Fecha de Ingreso: noviembre-2007
Mensajes: 12
Antigüedad: 16 años, 5 meses
Puntos: 0
Recorrer un mysql_fecth_array

Buenas, estoy intentando recorrer una consulta sql que tiene 3 filas como resultado

$sqlnombres="SELECT nombre FROM `cliente` ORDER BY nombre";
$nombres=generaSQL($sqlnombres,$conexion); //aki me devuelve el array

for($index=0;$totalnombres>0;$index++)
{
$nombre=$nombres[$index];
echo $nombre;
$totalnombres--;
}

no se si uso mal el mysql_fetch_Array o es ke tengo ke escoger otro

soy novato [L] :P


saludos y gracias
  #2 (permalink)  
Antiguo 09/11/2007, 12:24
Avatar de tricampeon27  
Fecha de Ingreso: enero-2007
Ubicación: Macul
Mensajes: 300
Antigüedad: 17 años, 3 meses
Puntos: 0
Re: Recorrer un mysql_fecth_array

con este codigo puedes reccorrer un select

include "conexion.php" ;

//rescato user y pasword
$rut = $_POST["rut"];
$usuvrtrut = $_POST["usuvrtrut"];
//echo "rut $rut";

//sleep(3);

// llamo sp que valida user y pasowrd
$result = mysqli_query($conexion,"call sp_select_usuarios($rut);");
if (! $result)
{
die('[index.php:] error de mysql_querry ' . mysql_error());
exit;
}
// extrae datos de la bd

if ($row = mysqli_fetch_array($result,MYSQLI_NUM))
{
do
{

//while ($row = mysqli_fetch_array($result,MYSQLI_NUM))

$id = $row[0];
echo "retorno id: $id\n";
$idd = $row[1];
exit;
if ($id == 1)
{
echo"<meta http-equiv='refresh' CONTENT='0;URL=fra_contenedorSuper.php'>";
exit;
}
if ($id == 2)
{
echo"<meta http-equiv='refresh' CONTENT='0;URL=fra_contenedor.php'>";
exit;
}
if ($id <> 1 || $id <> 2)
echo "<div id='Layer2' style='position:absolute; left:490px; top:320px; width:240px; height:55px; z-index:1'> <table width='100%' border='2' align=center ><td><CENTER>Usuario No Registrado</CENTER></td></font></div>";
}
while ($row = mysqli_fetch_array($result,MYSQLI_NUM));
}
} // fin del if post
__________________
*****Si Hasta En La Cana X Ti Estado*****
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 04:29.