[FX.php List] Creating summaries on the fly,

Steve Winter steve at bluecrocodile.co.nz
Tue Aug 22 21:41:11 MDT 2006


Hi Bob,

Rather than outputting the results direct to the HTML page, why not store
them in an array using PHP, thus;
  $cars['type1'] = 5;
  $cars['type2'] = 10;
  $cars....
then you could output the data, and create the % as you go;
  foreach($cars as $key = $value)
    echo $key.' = '.$value.(($value / $counter) * 100).'%';

You'll want to do some rounding on your percentages, but this should be
able to do what you want...?

Let me know if I've missed something..

Cheers
Steve



then once you'd got to the end, you would know the total (called say $counter)

> Thanks for the reply.
> 
> Unfortunately, that won't work, since I have no way of knowing how  
> many subsummaries there will be, or how many totals there will be for  
> each category.
> 
> I originally thought about doing this in the database itself, but  
> summarizing in PHP works great. The only catch is these percentages...
> 
> At this point I'm not too concerned about the non-Javascript folks;  
> if they want to use the reports and get all the data, they'll have to  
> have Javascript. The question is, how to plug a piece of text into a  
> page.
> 
> I know how to populate a form field in JS, but how do I insert a  
> piece of text somewhere in an HTML (actually of course PHP) page?
> 
> Thanks,
> 
> Bob Patin
> Longterm Solutions
> bob at longtermsolutions.com
> 615-333-6858
> http://www.longtermsolutions.com
> 
>    CONTACT US VIA INSTANT MESSAGING:
>       AIM or iChat: longterm1954
>       Yahoo: longterm_solutions
>       MSN: tech at longtermsolutions.com
>       ICQ: 159333060
> 
> 
> On Aug 22, 2006, at 10:02 PM, Kevin Futter wrote:
> 
> > JavaScript could work, with the potential problem that JS- 
> > disadvantaged folk
> > won't see anything. I think if it were me, I'd try putting the  
> > whole FM call
> > and data processing loop in a function, which also returns a variable
> > containing the final figures you need. That way you can take the  
> > function's
> > output (containing the FM data and your custom variable/s) and  
> > process and
> > display them as required. Of course, I say all this off the top of  
> > my head
> > and without any insight into how your code currently works.
> 
> 




More information about the FX.php_List mailing list