You are here: Re: Rookie PHP/MySQL Question « All PHP « IT news, forums, messages
Re: Rookie PHP/MySQL Question

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация