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

Dale Bengston dbengston at preservationstudio.com
Tue Aug 22 22:09:12 MDT 2006


Bob,

Are you writing your sub-summaries to the page as you go through the  
all the records, or are you making an array first and then writing  
from the created array?

Dale

On Aug 22, 2006, at 11:01 PM, Bob Patin wrote:

> Dale,
>
> Makes sense, but that's not the problem. I've already gotten my  
> page to show summaries and subsummaries. What I need is to show the  
> percentage of the subsummary total for each LINE of the subsummary.  
> Here's what I'd like to have:
>
>
> Total vehicles	25 (from foundCount)
>
> Ford Taurus	3	30% <-- this is what I need to insert after the  
> foreach loop
> Ford Focus	7	70% <-- ditto here
>
> Total Fords	10	40%	(I can get this because I already know the  
> foundcount)
>
> Honda Accord	5	33%
> Honda CRX	10	67%
>
> Total Hondas	15	60%	(also obtainable because I know the foundcount)
>
> Unless I'm missing something in your example...
>
> Bob
>
>
> On Aug 22, 2006, at 10:55 PM, Dale Bengston wrote:
>
>> Hey Bob,
>>
>> This is just hacked up in the email, so I don't guarantee every  
>> line. As you're ticking through your records, increment some array  
>> elements based on your summary field content....
>>
>> $summaryCount = array();
>> $recCount = 0;
>>
>> foreach ($theRecords as $key => $value)
>> 	{
>> 	$summaryCount[$value['myField'][0]]++;
>>
>> 	[...other stuff]
>> 	$recCount++;
>> 	}
>>
>>
>> This creates an array element for each subcategory and increments  
>> it on the fly. When the foreach is done processing, you have a  
>> count of each subcategory, plus a total count of records. The  
>> percentage of each subcategory is...
>>
>> ($summaryCount['whatever'] / $recCount) * 100;
>>
>> Am I making sense at this hour?
>>
>> Dale
>>
>> On Aug 22, 2006, at 10:44 PM, Kevin Futter wrote:
>>
>>> On 23/8/06 1:06 PM, "Bob Patin" <bob at patin.com> wrote:
>>>
>>>> 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?
>>>>
>>> Well, probably the simplest method would be to create an empty  
>>> element on the page to contain the percentage info – I don’t know  
>>> your page structure so I’ll leave it to you to decide what the  
>>> most semantic choice of element is. You’ll need to give it an ID,  
>>> so if you require more than one, append an incrementing number to  
>>> the ID name (eg, id-name1, id-name2 etc).
>>>
>>> The JS would need to contain a line like so:
>>>
>>> document.getElementById(“id-name1”).innerHTML = “30%”;
>>>
>>> I can elaborate further with a complete script example if you  
>>> need it.
>>>
>>>
>>> If this email is spam, report it here:
>>> http://www.OnlyMyEmail.com/ReportSpam --
>>> Kevin Futter
>>> Webmaster, St. Bernard's College
>>> http://www.sbc.melb.catholic.edu.au/
>>>
>>> ------------------------------------------
>>> This e-mail and any attachments may be confidential. You must not  
>>> disclose or use the information in this e-mail if you are not the  
>>> intended recipient. If you have received this e-mail in error,  
>>> please notify us immediately and delete the e-mail and all  
>>> copies. The College does not guarantee that this e-mail is virus  
>>> or error free. The attached files are provided and may only be  
>>> used on the basis that the user assumes all responsibility for  
>>> any loss, damage or consequence resulting directly or indirectly  
>>> from the use of the attached files, whether caused by the  
>>> negligence of the sender or not. The content and opinions in this  
>>> e-mail are not necessarily those of the College.
>>> _______________________________________________
>>> 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
>>
>>
>>
>> --
>> If this email is spam, report it here:
>> http://www.OnlyMyEmail.com/reportSpam? 
>> Id=NDIyMTM6MTU3ODY3NDYzOmJvYkBwYXRpbi5jb20%3D
>
> _______________________________________________
> 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/20060822/1a41a859/attachment.html


More information about the FX.php_List mailing list