[FX.php List] Can you pull from array?

DC dan.cynosure at dbmscan.com
Tue Oct 17 19:10:31 MDT 2006


hi david,

ok, i think i get what you want to do.

i see from the original code you posted that there is a problem  
before you get to your stated problem. you pass 15 as your limit for  
returns yet you use the $popularResult['foundCount'] FX.php array  
item to do your iterations. these two numbers can and will be  
different. the limit (15) is a number you pass to tell FMP WPE to  
only return a subset of results. so, for example, if your find  
request found 1000 records the code you wrote below will find ALL  
1000 and foundCount will be 1000 but your $popularResult['data']  
array item from FX.php will only carry 15 of those 1000 records.

i think that is *not* what you were asking about but since i'm  
looking at your code i thought i'd mention it as a potential problem.

anyway, the typical way to get field data from FX.php results is by  
using the FX.php data array item:

$popularResult['data']

so how about something like this to display the data (untested code  
but should work):

foreach ($popularResult['data'] as $record) {
	echo "<td>$record['fieldName'][0]</td>";
}

i know you said you didn't want foreach, but i'm not sure why... it's  
clear and standard PHP coding and it makes it easy to deal with  
FX.php's data. using for() or while() to iterate the data array is  
annoying since you don't have a numerical index to rely on; the  
indexing is based on recid and modification count!

cheers,
dan

On Oct 17, 2006, at 5:55 PM, David Tinoco wrote:

> Hello Everyone,
>
> Is there a way to pull out certain arrays from the FX Data array?
>
> I will give an example.
>
> 1. Let's say you do a find:
>
> $popular=new FX($serverIP,$webCompanionPort);
> $popular->SetDBData('File.fp7','Popular Searches',15);
> $popular->SetDBPassword($webPW,$webUN);
> $popularResult=$popular->FMFind();
>
> Now, I want to put these 15 results into a table 3 columns wide by  
> 5 rows tall.
>
> $cells=$popularResult['foundCount'];
> $curcells=$cells;
> $rows=ceil($cells/3);
> $falsecells=$rows*3;
> $leftcells=$falsecells-$cells;
> $currows=0;
> while($currows<$rows && $cells-1>$leftcells)
> {
> echo'<td class="Bold11_Blue2">This is a test</td>';
> $curcells=$curcells-1;
> if($cells-$curcells==3)
>  {
>  echo'</tr><tr>';
>  $cells=$curcells;
>  $currows++;
>  }
> }
> If($cells>0)
> {
> for($num=0;$num<$cells;$num++)
> {
> echo'<td>This is a test</td>';
> }
> }
>
> Now I just want to replace where it says "This is a test" with a  
> field from the find. Is there something like an array that I can  
> use instead of using the foreach ($popularResult as $key => 
> $popularData['Field'][0]), with a counter using i++ or something?
>
> Thanks,
> David
>
> Express yourself - download free Windows Live Messenger themes! Get  
> it now!
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.iviking.org/pipermail/fx.php_list/attachments/20061017/387c29c8/attachment.html


More information about the FX.php_List mailing list