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-
[Back to original message]
|