|
Posted by Rik on 10/10/68 11:33
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
Navigation:
[Reply to this message]
|