Click here to get back home

Re: Pre-Analyze a PHP page?

 HomeNewsGroups | Search | About
 comp.lang.php    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Re: Pre-Analyze a PHP page? Iván Sánchez 06-11-2008
Get Chitika Premium
Posted by Iván Sánchez on June 11, 2008, 4:11 pm
Please log in for more thread options
Mo wrote:

> I'm a novice looking for suggestions.
>
> I have a report which is now working how I want it, but I need to add
> some calculated totals.
> The problem is that I need to put the sum of detail above (prior to)
> the detail itself.
>
> Is there a way to pre-analyze the page or something so that I can use
> the sum prior to the getting the parts that make the sum?

Instead of echo()ing everything, store it in a string variable. Then, sum
what you need to, then echo() the sum, then echo() the string holding the
(delayed) output.

Cheers,
--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

A Tale of Two Cities LITE(tm)
-- by Charles Dickens

A man in love with a girl who loves another man who looks just
like him has his head chopped off in France because of a mean
lady who knits.

Crime and Punishment LITE(tm)
-- by Fyodor Dostoevski

A man sends a nasty letter to a pawnbroker, but later
feels guilty and apologizes.

The Odyssey LITE(tm)
-- by Homer

After working late, a valiant warrior gets lost on his way home.


Posted by Mo on June 11, 2008, 6:32 pm
Please log in for more thread options
On Jun 11, 12:11=A0pm, Iv=E1n S=E1nchez Ortega <ivansanchez-...@rroba-
escomposlinux.-.punto.-.org> wrote:
> Mo wrote:
> > I'm a novice looking for suggestions.
>
> > I have a report which is now working how I want it, but I need to add
> > some calculated totals.
> > The problem is that I need to put the sum of detail above (prior to)
> > the detail itself.
>
> > Is there a way to pre-analyze the page or something so that I can use
> > the sum prior to the getting the parts that make the sum?
>
> Instead of echo()ing everything, store it in a string variable. Then, sum
> what you need to, then echo() the sum, then echo() the string holding the
> (delayed) output.
>
> Cheers,
> --
> ----------------------------------
> Iv=E1n S=E1nchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-
>
> A Tale of Two Cities LITE(tm)
> =A0 =A0 =A0 =A0 -- by Charles Dickens
>
> =A0 =A0 =A0 =A0 A man in love with a girl who loves another man who looks =
just
> =A0 =A0 =A0 =A0 like him has his head chopped off in France because of a m=
ean
> =A0 =A0 =A0 =A0 lady who knits.
>
> Crime and Punishment LITE(tm)
> =A0 =A0 =A0 =A0 -- by Fyodor Dostoevski
>
> =A0 =A0 =A0 =A0 A man sends a nasty letter to a pawnbroker, but later
> =A0 =A0 =A0 =A0 feels guilty and apologizes.
>
> The Odyssey LITE(tm)
> =A0 =A0 =A0 =A0 -- by Homer
>
> =A0 =A0 =A0 =A0 After working late, a valiant warrior gets lost on his way=
home.

I don't think I can just store it into a variable for delayed output
because it has to be in the WHILE loop for it to itterate correctly.
If I'm wrong on this, PLEASE correct me.
I'd love to be able to do it this way (i tried something like this,
but couldn't get it to work).

~Mo

Posted by Iván Sánchez on June 11, 2008, 8:26 pm
Please log in for more thread options
Mo wrote:

> I don't think I can just store it into a variable for delayed output
> because it has to be in the WHILE loop for it to itterate correctly.
> If I'm wrong on this, PLEASE correct me.

You're wrong.

It should work like this:

<?php
$output='';

while($condition)
{
$output .= "Whatever";
}

echo $output;
?>

Note the use of the .= operator, check the PHP manual if you have any doubts
about how .= works.

Cheers,
--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

Un ordenador no es un televisor ni un microondas, es una herramienta
compleja.

Posted by Jerry Stuckle on June 12, 2008, 12:38 am
Please log in for more thread options
Mo wrote:
> On Jun 11, 12:11 pm, Iván Sánchez Ortega <ivansanchez-...@rroba-
> escomposlinux.-.punto.-.org> wrote:
>> Mo wrote:
>>> I'm a novice looking for suggestions.
>>> I have a report which is now working how I want it, but I need to add
>>> some calculated totals.
>>> The problem is that I need to put the sum of detail above (prior to)
>>> the detail itself.
>>> Is there a way to pre-analyze the page or something so that I can use
>>> the sum prior to the getting the parts that make the sum?
>> Instead of echo()ing everything, store it in a string variable. Then, sum
>> what you need to, then echo() the sum, then echo() the string holding the
>> (delayed) output.
>>
>> Cheers,
>> --
>> ----------------------------------
>> Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-
>>
>> A Tale of Two Cities LITE(tm)
>> -- by Charles Dickens
>>
>> A man in love with a girl who loves another man who looks just
>> like him has his head chopped off in France because of a mean
>> lady who knits.
>>
>> Crime and Punishment LITE(tm)
>> -- by Fyodor Dostoevski
>>
>> A man sends a nasty letter to a pawnbroker, but later
>> feels guilty and apologizes.
>>
>> The Odyssey LITE(tm)
>> -- by Homer
>>
>> After working late, a valiant warrior gets lost on his way home.
>
> I don't think I can just store it into a variable for delayed output
> because it has to be in the WHILE loop for it to itterate correctly.
> If I'm wrong on this, PLEASE correct me.
> I'd love to be able to do it this way (i tried something like this,
> but couldn't get it to work).
>
> ~Mo
>

Iván is correct. With proper programming, you can do this rather easily.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================


Posted by Mo on June 12, 2008, 11:52 am
Please log in for more thread options
> Mo wrote:
> > On Jun 11, 12:11 pm, Iv=E1n S=E1nchez Ortega <ivansanchez-...@rroba-
> > escomposlinux.-.punto.-.org> wrote:
> >> Mo wrote:
> >>> I'm a novice looking for suggestions.
> >>> I have a report which is now working how I want it, but I need to add
> >>> some calculated totals.
> >>> The problem is that I need to put the sum of detail above (prior to)
> >>> the detail itself.
> >>> Is there a way to pre-analyze the page or something so that I can use
> >>> the sum prior to the getting the parts that make the sum?
> >> Instead of echo()ing everything, store it in a string variable. Then, s=
um
> >> what you need to, then echo() the sum, then echo() the string holding t=
he
> >> (delayed) output.
>
> >> Cheers,
> >> --
> >> ----------------------------------
> >> Iv=E1n S=E1nchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-=

>
> >> A Tale of Two Cities LITE(tm)
> >> =A0 =A0 =A0 =A0 -- by Charles Dickens
>
> >> =A0 =A0 =A0 =A0 A man in love with a girl who loves another man who loo=
ks just
> >> =A0 =A0 =A0 =A0 like him has his head chopped off in France because of =
a mean
> >> =A0 =A0 =A0 =A0 lady who knits.
>
> >> Crime and Punishment LITE(tm)
> >> =A0 =A0 =A0 =A0 -- by Fyodor Dostoevski
>
> >> =A0 =A0 =A0 =A0 A man sends a nasty letter to a pawnbroker, but later
> >> =A0 =A0 =A0 =A0 feels guilty and apologizes.
>
> >> The Odyssey LITE(tm)
> >> =A0 =A0 =A0 =A0 -- by Homer
>
> >> =A0 =A0 =A0 =A0 After working late, a valiant warrior gets lost on his =
way home.
>
> > I don't think I can just store it into a variable for delayed output
> > because it has to be in the WHILE loop for it to itterate correctly.
> > If I'm wrong on this, PLEASE correct me.
> > I'd love to be able to do it this way (i tried something like this,
> > but couldn't get it to work).
>
> > ~Mo
>
> Iv=E1n is correct. =A0With proper programming, you can do this rather easi=
ly.
>
> --
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D- Hide quoted text -=

>
> - Show quoted text -

WOW!
That's great!

I think I understand how the .=3D operator works, but I'm not quite
grasping the logic.
I am hoping that the manual has some examples, but I can't pull it up
in the manual (I'm using the online version).
If you could provide some tips on how to find it (and/or point me to
some examples), it'd be greatly appreciated.

~Mo

Similar ThreadsPosted
session var is setting ONLY AFTER I reload page, form var displays first page load July 23, 2004, 5:16 pm
Web clipping of a "remote" web page for insertion into a "local" page: is it possible? December 12, 2006, 10:47 am
Session variables are lost, disappear from page to page March 6, 2008, 1:27 pm
i am trying to setup a link in my page that will change my page May 16, 2006, 10:11 pm
question about using "global" on one page then using the variable on another page April 5, 2007, 1:28 pm
restrict page access to one referring page June 30, 2008, 2:57 pm
I want to create something like AMAZON: those who liked page A also liked page B October 26, 2005, 2:09 pm
Passing variables from a PHP page to an ASP page? December 6, 2005, 8:57 pm
HTML web page hyperlink to php web page February 14, 2006, 3:25 pm
Using PHP to load another page or html page March 22, 2006, 1:10 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap