You are here: Re: mySQL result to real array in function « PHP Programming Language « IT news, forums, messages
Re: mySQL result to real array in function

Posted by David Haynes on 04/25/06 22:28

frizzle wrote:
> David Haynes wrote:
>> $result[] = causes the result to be pushed onto an indexed array not an
>> associative array. See inline for fix.
>>
>> -david-
>>> $get_res = mysql_query(QUERY);
>>>
>>> if( $res = mysql_fetch_array( $get_res ) )
>>> {
>>>
>>> do{
>>>
>> $result[$res['field1']] = $res['field1 value'];
>>> } while( $res = mysql_fetch_array( $get_res ) );
>>>
>>> };
>>>
>>> foreach( $result as $key => $value ){
>>>
>>> print_r($value);
>>>
>>> };
>
> David,
>
> i don't alwas know all fieldnames beforehand.
> So SELECT * should also put all fieldnames as
> keys in the array.
>
> Frizzle.
>
My assumption was that one column in the table being queried formed the
keys for the associative array. If so, then my method works. If not,
what were you planning on using as the key to the array?

-david-

 

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

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