georg           Sun Apr 21 10:45:01 2002 EDT

  Modified files:              
    /phpdoc/en/reference/mysql/functions        mysql-fetch-array.xml 
  Log:
  inserted additional samples
  
  
Index: phpdoc/en/reference/mysql/functions/mysql-fetch-array.xml
diff -u phpdoc/en/reference/mysql/functions/mysql-fetch-array.xml:1.2 
phpdoc/en/reference/mysql/functions/mysql-fetch-array.xml:1.3
--- phpdoc/en/reference/mysql/functions/mysql-fetch-array.xml:1.2       Wed Apr 17 
02:41:10 2002
+++ phpdoc/en/reference/mysql/functions/mysql-fetch-array.xml   Sun Apr 21 10:45:01 
+2002
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
 <!-- splitted from ./en/functions/mysql.xml, last change in rev 1.27 -->
   <refentry id="function.mysql-fetch-array">
    <refnamediv>
@@ -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
      <literal>'field'</literal> in this example).
-     <informalexample>
+     <example>
+      <title>Query with duplicate field names</title>
       <programlisting role="sql">
 <![CDATA[
-select tone.field as foo ttwo.field as bar from tone, ttwo
+select table1.field as foo table2.field as bar from table1, table2
 ]]>
       </programlisting>
-     </informalexample>
+     </example>
     </para>
     <para>
      An important thing to note is that using
@@ -62,30 +63,62 @@
      using MYSQL_NUM, you only get number indices (as
      <function>mysql_fetch_row</function> works).
     </para>
-    <para>
-     For further details, see also
-     <function>mysql_fetch_row</function> and
-     <function>mysql_fetch_assoc</function>.
-    </para>
     <example>
-     <title><function>mysql_fetch_array</function> example</title>
+     <title>mysql_fetch_array with MYSQL_NUM</title>
+     <programlisting role="php">
+<![CDATA[
+<?php
+    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);
+?>
+]]>
+     </programlisting>
+    </example>
+    <example>
+     <title>mysql_fetch_array with MYSQL_ASSOC</title>
      <programlisting role="php">
 <![CDATA[
 <?php
-    mysql_connect($host, $user, $password);
-    mysql_select_db("database");
-    $result = mysql_query("select user_id, fullname from table");
-    while ($row = mysql_fetch_array($result)) {
-        echo "user_id: ".$row["user_id"]."<br />\n";
-        echo "user_id: ".$row[0]."<br />\n";
-        echo "fullname: ".$row["fullname"]."<br />\n";
-        echo "fullname: ".$row[1]."<br />\n";
-    }
+    mysql_connect("localhost", "mysql_user", "mysql_password");
+
+    $result = mysql_query("SELECT id, name FROM mytable");
+
+    while (($row = mysql_fetch_array($result, MYSQL_ASSOC))
+        printf ("ID: %s  Name: %s", $row["id"], $row["name"]);  
+
     mysql_free_result($result);
 ?>
 ]]>
      </programlisting>
     </example>
+    <example>
+     <title>mysql_fetch_array with MYSQL_BOTH</title>
+     <programlisting role="php">
+<![CDATA[
+<?php
+    mysql_connect("localhost", "mysql_user", "mysql_password");
+
+    $result = mysql_query("SELECT id, name FROM mytable");
+
+    while (($row = mysql_fetch_array($result, MYSQL_BOTH))
+        printf ("ID: %s  Name: %s", $row[0], $row["name"]);  
+
+    mysql_free_result($result);
+?>
+]]>
+     </programlisting>
+    </example>
+    <para>
+     For further details, see also
+     <function>mysql_fetch_row</function> and
+     <function>mysql_fetch_assoc</function>.
+    </para>
    </refsect1>
   </refentry>
 


Reply via email to