You can also do


$macroDataArray = mysql_fetch_array($result,MYSQL_ASSOC)

foreach(array_keys($macroDataArray) as $elementkey){

        echo "Value for key $elementKey = $macroDataArray[$elementKey]<br>\n";



(mysql_fetch_array uses MYSQL_BOTH for the second argument by default, which
returns an array using both numeric and associative keys - that's why you
were getting double results. :))

Per the manual:

The optional second argument result_type in mysql_fetch_array() is a
constant and can take the following values: MYSQL_ASSOC, MYSQL_NUM, and
MYSQL_BOTH. This feature was added in PHP 3.0.7. MYSQL_BOTH is the default
for this argument.

By using MYSQL_BOTH, you'll get an array with both associative and number
indices. 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).



> -----Original Message-----
> From: Chris Boget [mailto:[EMAIL PROTECTED]]
> > $macroDataArray = mysql_fetch_array( $result );
> I'm still curious what is going wrong, but I've found a work arround.
> One of the things I love about PHP is that you learn something new
> just about every day.  Instead of fetch_array(), I can use fetch_assoc()
> and it'll do just what I need. :)

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to