From 1d60d615a463b0c5d80953d1b8a7dd89de73ae0c Mon Sep 17 00:00:00 2001 From: Georg Richter Date: Sun, 21 Apr 2002 14:45:01 +0000 Subject: [PATCH] inserted additional samples git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@79309 c90b9560-bf6c-de11-be94-00142212c4b1 --- .../mysql/functions/mysql-fetch-array.xml | 71 ++++++++++++++----- 1 file changed, 52 insertions(+), 19 deletions(-) diff --git a/reference/mysql/functions/mysql-fetch-array.xml b/reference/mysql/functions/mysql-fetch-array.xml index 0a7df05249..98c89e9358 100644 --- a/reference/mysql/functions/mysql-fetch-array.xml +++ b/reference/mysql/functions/mysql-fetch-array.xml @@ -1,5 +1,5 @@ - + @@ -33,13 +33,14 @@ make an alias for the column. For aliased columns, you cannot access the contents with the original column name (by using 'field' in this example). - + + Query with duplicate field names - + An important thing to note is that using @@ -62,30 +63,62 @@ select tone.field as foo ttwo.field as bar from tone, ttwo using MYSQL_NUM, you only get number indices (as mysql_fetch_row works). - - For further details, see also - mysql_fetch_row and - mysql_fetch_assoc. - - <function>mysql_fetch_array</function> example + mysql_fetch_array with MYSQL_NUM \n"; - echo "user_id: ".$row[0]."
\n"; - echo "fullname: ".$row["fullname"]."
\n"; - echo "fullname: ".$row[1]."
\n"; - } + mysql_connect("localhost", "mysql_user", "mysql_password"); + + $result = mysql_query("SELECT id, name FROM mytable"); + + while (($row = mysql_fetch_array($result, MYSQL_NUM)) + printf ("ID: %s Name: %s", $row[0], $row[1]); + mysql_free_result($result); ?> ]]>
+ + mysql_fetch_array with MYSQL_ASSOC + + +]]> + + + + mysql_fetch_array with MYSQL_BOTH + + +]]> + + + + For further details, see also + mysql_fetch_row and + mysql_fetch_assoc. +