Join Up!
96806 members and counting!

 
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links 
search for in the  
previousmysql_escape_stringmysql_fetch_assocnext
Last updated: Tue, 29 Oct 2002
view the printer friendly version or the printer friendly version with notes or change language to Czech | Finnish | German

mysql_fetch_array

(PHP 3, PHP 4 )

mysql_fetch_array --  Extrae la fila de resultado como una matriz asociativa

Descripción

array mysql_fetch_array ( int id_resultado [, int tipo_de_resultado])

Devuelve una matriz que corresponde a la sentencia extraida, o falso si no quedan más filas.

mysql_fetch_array() es una versión extendida de mysql_fetch_row(). Además de guardar los datos en el indice numerico de la matriz, guarda también los datos en los indices asociativos, usando el nombre de campo como clave.

Si dos o más columnas del resultado tienen el mismo nombre de campo, la última columna toma la prioridad. Para acceder a la(s) otra(s) columna(s) con el mismo nombre, se debe escificar el indice numerico o definir un alias para la columna.

select t1.f1 as foo t2.f1 as bar from t1, t2

La función mysql_fetch_array() no es significativemente mas lenta que mysql_fetch_row(), sin embargo tiene un valor añadido importante.

El segundo argumento opcional tipo_de_resultado en mysql_fetch_array() es una constante y puede tomar los valores siguientes: MYSQL_ASSOC, MYSQL_NUM, y MYSQL_BOTH. (Esta funcionalidad fue añadida en PHP 3.0.7)

Para más detalles, ver también mysql_fetch_row().

Ejemplo 1. mysql fetch array

<?php
mysql_connect($host,$user,$password);
$result = mysql_db_query("database","select * from table");
while($row = mysql_fetch_array($result)) {
    echo $row["user_id"];
    echo $row["fullname"];
}
mysql_free_result($result);
?>
User Contributed Notes
mysql_fetch_array
add a note about notes
There are no user contributed notes for this page.
previousmysql_escape_stringmysql_fetch_assocnext
Last updated: Tue, 29 Oct 2002
Copyright © 2001, 2002 The PHP Group
All rights reserved.
This mirror generously provided by: http://phpbuilder.com/
Last updated: Thu Oct 31 18:34:28 2002 EST