Ver Mensaje Individual
  #1 (permalink)  
Antiguo 24/09/2010, 17:28
auranegra
 
Fecha de Ingreso: abril-2007
Mensajes: 26
Antigüedad: 17 años, 1 mes
Puntos: 0
Duda sobre If Y While

Buenas tardes amigos.

Mi duda es la siguiente estoy seguro que ustedes podran ayudarme.

este es mi script:
Código:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Documento sin título</title>
</head>

<body>
<?php

$conexion=mysql_connect('localhost','root','1234'); 
$consulta=mysql_db_query('almacen', 'SELECT * FROM almacen_caba'); 
while ($valores = mysql_fetch_array($consulta)) 
{ 
print " <LI>id: " . $valores["id"] . "<BR>\n"; 
print " ingreso: " . $valores["ingreso"] . "<BR>\n"; 
print " salida: " . $valores["salida"] . "<BR>\n"; 
print " stock: " . $valores["stock"] . "<BR>\n";  
}
mysql_free_result($consulta); 
mysql_close(); 

?> 


</body>
</html>
Entonces, cuando utilizo while me da como resultado lo siguiente:
Código:
id: 1
ingreso: 
salida: 
stock: 0
id: 2
ingreso: 
salida: 
stock: 0
id: 3
ingreso: 
salida: 
stock: 0
id: 4
ingreso: 
salida: 
stock: 0
id: 5
ingreso: 
salida: 
stock: 0
id: 6
ingreso: 
salida: 
stock: 0
id: 7
ingreso: 
salida: 
stock: 0
id: 8
ingreso: 
salida: 
stock: 0
Y cuando utilizo If en lugar de While me arroja un solo registro:
Código:
id: 1
ingreso: 
salida: 
stock: 0
Quiero saber porque sucede esto. Gracias a todos.