[thelist] mysql_fetch_array() - choosing numeric or associative indices

Joel Canfield joel at spinhead.com
Sun Jul 7 14:03:01 CDT 2002

Zend says concerning mysql_fetch_array(): "Using MYSQL_ASSOC, you only get
associative indices (as mysql_fetch_assoc() works), using MYSQL_NUM, you
only get number indices (as  mysql_fetch_row() works)."

So, if I only want the associative indices, is there a reason to use
mysql_fetch_array() instead of mysql_fetch_assoc() ?

Related question: if the "significant added value" of mysql_fetch_array() is
the ability to retrieve both numeric and associative indices, how do I
separate them? F'rinstance, this bit:

    while ($line = mysql_fetch_array($result, MYSQL_BOTH))
        print "\t<tr>\n";
        foreach ($line as $col_value)
            print "\t\t<td>$col_value</td>\n";
        print "\t</tr>\n";

returns each field twice. Is there a mechanism to choose the numeric or
associative index on the fly?

Am I missing something I should be seeing?



More information about the thelist mailing list