[FX.php List] Pulling data directly from findResult

Bob Patin bob at patin.com
Thu Oct 16 15:24:49 MDT 2008


Why don't you just use the FOREACH statement like guys usually do? Am  
I missing something here?

Just use this:

... query here...
$queryResult = $query->Find();
// error processing code would go in here



// loop through foundset and do your stuff
foreach($queryResult['data'] as $key=>$queryData){
	... do what you want in here, add table rows or whatever...

} // end the FOREACH loop

I've done all sorts of loops with data; you don't of course HAVE to  
put the FOREACH statement right after the query. I do the query at the  
top of the page, and then I embed the FOREACH wherever I need it.

BP

Bob Patin
Longterm Solutions
bob at longtermsolutions.com
615-333-6858
http://www.longtermsolutions.com
iChat: bobpatin
AIM: longterm1954
FileMaker 9 Certified Developer
Member of FileMaker Business Alliance and FileMaker TechNet
--------------------------
FileMaker hosting and consulting for all versions of FileMaker
PHP • Full email services • Free DNS hosting • Colocation • Consulting



On Oct 16, 2008, at 10:45 AM, Jonathan Schwartz wrote:

> Want to display one record at a time from found set.
> Is there a better way to approach this?
>
> I don't see the difference between the two examples below that would  
> cause records 1 to echo on the first line and then record 2 to  
> display in the second.  Does "key" automatically increment itself?
>
> In any event, I just want to be able to start at the first and then  
> manually walk to the next, etc.
>
> I expect to use a counter.
>
> J
>
> At 11:20 AM -0400 10/16/08, Gareth Evans wrote:
>> Here's one way to manually step through the result array using  
>> each().
>>
>> //record 1
>> $rec = each($findResult['data']);
>> echo $findResult['data'][$rec['key']]['desiredfieldname'][0];
>>
>> // record 2
>> $rec = each($findResult['data']);
>> echo $findResult['data'][$rec['key']]['desiredfieldname'][0];
>>
>> Don't know why you wouldn't want to use a loop of some sort though...
>> --
>> GARETH EVANS
>>
>>
>>> From: Jonathan Schwartz <jschwartz at exit445.com>
>>> Reply-To: "FX.php Discussion List" <fx.php_list at mail.iviking.org>
>>> Date: Thu, 16 Oct 2008 08:02:34 -0700
>>> To: "FX.php Discussion List" <fx.php_list at mail.iviking.org>
>>> Subject: Re: [FX.php List] Pulling data directly from findResult
>>>
>>> Great!  That seems to retrieve the first one.  How do I call others
>>> in the array?
>>>
>>> J
>>>
>>> At 4:43 PM +0200 10/16/08, Gjermund Gusland Thorsen wrote:
>>>> echo $findResult['data'][key($findResult['data'])] 
>>>> ['desiredfieldname'][0];
>>>>
>>>> ggt
>>>>
>>>> 2008/10/16 Jonathan Schwartz <jschwartz at exit445.com>:
>>>>>  Hi Foks,
>>>>>
>>>>>  Instead of using foreach, how can data be pulled from the  
>>>>> $FindResult
>>>>> array?
>>>>>
>>>>>  Trying syntax such as this, without result:
>>>>>
>>>>>  $desireddatavalue = $findResult['data'] ['desiredfieldname']
>>>>>
>>>>>  I know it's not right.  I'm just missing that last syntax  
>>>>> step....I think.
>>>>>
>>>>>  Assume that I want to manually step through found records,  
>>>>> string with
>>>>>  first.
>>>>>
>>>>>  Thanks
>>>>>
>>>>>  Jonathan
>>>>>
>>>>>  --
>>>>>  Jonathan Schwartz
>>>>>  Exit 445 Group
>>>>>  jonathan at exit445.com
>>>>>  http://www.exit445.com
>>>>>  415-370-5011
>>>>>  _______________________________________________
>>>>>  FX.php_List mailing list
>>>>>  FX.php_List at mail.iviking.org
>>>>>  http://www.iviking.org/mailman/listinfo/fx.php_list
>>>>>
>>>> _______________________________________________
>>>> FX.php_List mailing list
>>>> FX.php_List at mail.iviking.org
>>>> http://www.iviking.org/mailman/listinfo/fx.php_list
>>>
>>>
>>> --
>>> Jonathan Schwartz
>>> Exit 445 Group
>>> jonathan at exit445.com
>>> http://www.exit445.com
>>> 415-370-5011
>>> _______________________________________________
>>> FX.php_List mailing list
>>> FX.php_List at mail.iviking.org
>>> http://www.iviking.org/mailman/listinfo/fx.php_list
>>
>> _______________________________________________
>> FX.php_List mailing list
>> FX.php_List at mail.iviking.org
>> http://www.iviking.org/mailman/listinfo/fx.php_list
>
>
> -- 
> Jonathan Schwartz
> Exit 445 Group
> jonathan at exit445.com
> http://www.exit445.com
> 415-370-5011
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list



More information about the FX.php_List mailing list