You are here: Re: Iterating Over DB Results (Idiom?) « PHP Programming Language « IT news, forums, messages
Re: Iterating Over DB Results (Idiom?)

Posted by David Gillen on 05/09/07 15:23

john said:
> Now that I have the $result (a multidimensional array), what is the
> PHP idiom for iterating through the set, e.g., to create an HTML table
> of the data? Should I be thinking foreach() or something else?
>
Foreach would be the way to go. It doesn't care how many results there are
unlike other looping mechanisms which makes it the superior choice imho.

Typically though when looping over results from a database
while($row = fetchRowFromDB())
{
// Process Row

}

is the way it would be done.

But given you already have all rows retrieved foreach is preferable.

D.
--
Fermat was right.

 

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

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