|  | Posted by Ian Rutgers on 06/18/97 11:33 
"Rik" <luiheidsgoeroe@hotmail.com> wrote in message news:dmmjsg$ug5$1@netlx020.civ.utwente.nl...
 > Ian Rutgers wrote:
 >> and $my_array[] now stores the corrent number of image names!!  Why
 >> does the foreach(....) duplicate the entries?
 >
 > foreach isn't the problem.
 >
 > mysql_fetch_array does this:
 >
 > www.php.net:
 > mysql_fetch_array -- Fetch a result row as an associative array, a numeric
 > array, or _both_
 >
 > So is returns both numeric and named arrayvalues.
 > (For example: [key] => value:
 > [0] => value1
 > [name1] =>value1
 > [1] => value2
 > [name2] => value2)
 >
 > Use mysql_fetch_assoc, or mysql_fetch_array($bla, MYSQL_ASSOC) or
 > mysql_fetch_array($bla, MYSQL_NUM).
 >
 > In the second example you're only checking for named values, so it returns
 > just the one set, in the first you're accessing all values, also the
 > numeric.
 >
 > Grtz,
 >
 > Rik
 >
 >
 Thanks for the education!
  Navigation: [Reply to this message] |