473,807 Members | 2,827 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Re: Pre-Analyze a PHP page?

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.

Jun 27 '08 #1
16 1205
Mo
On Jun 11, 12:11*pm, Iván Sánchez Ortega <ivansanchez-...@rroba-
escomposlinux.-.punto.-.orgwrote:
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 wayhome.
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
Jun 27 '08 #2
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($conditio n)
{
$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.
Jun 27 '08 #3
Mo wrote:
On Jun 11, 12:11 pm, Iván Sánchez Ortega <ivansanchez-...@rroba-
escomposlinux.-.punto.-.orgwrote:
>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.
js*******@attgl obal.net
=============== ===

Jun 27 '08 #4
Mo
On Jun 11, 8:38*pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
Mo wrote:
On Jun 11, 12:11 pm, Iván Sánchez Ortega <ivansanchez-...@rroba-
escomposlinux.-.punto.-.orgwrote:
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.
jstuck...@attgl obal.net
=============== ===- Hide quoted text -

- Show quoted text -
WOW!
That's great!

I think I understand how the .= 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
Jun 27 '08 #5
Mo schreef:
On Jun 11, 8:38 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
>Mo wrote:
>>On Jun 11, 12:11 pm, Iván Sánchez Ortega <ivansanchez-...@rroba-
escomposlinux .-.punto.-.orgwrote:
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.
jstuck...@attg lobal.net
============== ====- Hide quoted text -

- Show quoted text -

WOW!
That's great!

I think I understand how the .= operator works, but I'm not quite
grasping the logic.
Hi,

..= is just a shothand.
$myVar = "hello";
$myVar = $myVar." Mo";
echo $myVar;

is the same as:
$myVar = "hello";
$myVar .= " Mo";
echo $myVar;

Both will echo: "hello Mo"

It is called string concatination (glueing of strings).

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).
Online version is great. Everything you need is in there.
Just get familiar with it. :-)

If you could provide some tips on how to find it (and/or point me to
some examples), it'd be greatly appreciated.
Use the search.
If you know a functionname, just type it in, and set the select on
'functions'.

If you don't know how something is named, well, that is more difficult.
Best is to browse a little through the manual.
Start here: http://nl3.php.net/manual/en/index.php

Good luck.

Regards,
Erwin Moller
>
~Mo
Jun 27 '08 #6
Mo
On Jun 12, 9:28*am, Erwin Moller
<Since_humans_r ead_this_I_am_s pammed_too_m... @spamyourself.c omwrote:
Mo schreef:


On Jun 11, 8:38 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
Mo wrote:
On Jun 11, 12:11 pm, Iván Sánchez Ortega <ivansanchez-...@rroba-
escomposlinu x.-.punto.-.orgwrote:
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 holdingthe
(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.
jstuck...@attgl obal.net
=============== ===- Hide quoted text -
- Show quoted text -
WOW!
That's great!
I think I understand how the .= operator works, but I'm not quite
grasping the logic.

Hi,

.= is just a shothand.
$myVar = "hello";
$myVar = $myVar." Mo";
echo $myVar;

is the same as:
$myVar = "hello";
$myVar .= " Mo";
echo $myVar;

Both will echo: "hello Mo"

It is called string concatination (glueing of strings).
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).

Online version is great. Everything you need is in there.
Just get familiar with it. :-)
If you could provide some tips on how to find it (and/or point me to
some examples), it'd be greatly appreciated.

Use the search.
If you know a functionname, just type it in, and set the select on
'functions'.

If you don't know how something is named, well, that is more difficult.
Best is to browse a little through the manual.
Start here:http://nl3.php.net/manual/en/index.php

Good luck.

Regards,
Erwin Moller


~Mo- Hide quoted text -

- Show quoted text -- Hide quoted text -

- Show quoted text -
Thanks.
I understand the logic and use of .= concatination, I'm hoping for an
example on this application of it.

Any advise?
Jun 27 '08 #7
..oO(Mo)
>I understand the logic and use of .= concatination, I'm hoping for an
example on this application of it.

Any advise?
Instead of directly printing out all the stuff you want to appear in the
browser with a bunch of echo or print statements, you simple write it to
a variable instead. Compare these two examples:

Direct print:

print 'foo';
print 'bar';
print 'something else';

With every print statement the data is immediately returned to the
browser and shown to the user (let aside output buffering, but that's a
different topic and doesn't matter here).

Now the delayed print:

$content = 'foo';
$content .= 'bar';
$content .= 'something else';

Until now nothing was returned to the browser, all the data was just
collected in the $content variable. The first statement directly assigns
the value 'foo' to it, the two following just append new data with the
concatenation operator. To return all the data at once to the browser
just do

print $content;

The result in the browser will be the same, just the way how it was
created on the server is different. With the second way you have more
control over the output and more flexibility in your application logic.

HTH
Micha
Jun 27 '08 #8
On Jun 12, 3:33 pm, Michael Fesser <neti...@gmx.de wrote:

Just an off-top add, guys:
The first statement directly assigns
the value 'foo' to it, the two following just append new data with the
concatenation operator.
Concatenation (this one) on PHP really means *append*? Or does it
assigns all the content of the variable plus the concatenated str?

for example:

$var = 'abc';
$var .= 'd';
//means this?
$var = 'abcd';
Thiago
Jun 27 '08 #9
..oO(Thiago Macedo)
>On Jun 12, 3:33 pm, Michael Fesser <neti...@gmx.de wrote:

Just an off-top add, guys:
>The first statement directly assigns
the value 'foo' to it, the two following just append new data with the
concatenatio n operator.

Concatenatio n (this one) on PHP really means *append*? Or does it
assigns all the content of the variable plus the concatenated str?
Does it make any difference? The result is the same.

The '.' concatenates two strings and returns the result, that's all.
It doesn't really matter how the engine handles this internally.
>for example:

$var = 'abc';
$var .= 'd';
//means this?
$var = 'abcd';
Yes.

Micha
Jun 27 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
18541
by: Alan Illeman | last post by:
How do I set several different properties for PRE in a CSS stylesheet, rather than resorting to this: <BODY> <PRE STYLE="font-family:monospace; font-size:0.95em; width:40%; border:red 2px solid; color:red;
2
2793
by: Buck Turgidson | last post by:
I want to have a css with 2 PRE styles, one bold with large font, and another non-bold and smaller font. I am new to CSS (and not exactly an expert in HTML, for that matter). Is there a way to do this in CSS? <STYLE TYPE="text/css"> pre{ font-size:xx-large;
5
718
by: Michael Shell | last post by:
Greetings, Consider the XHTML document attached at the end of this post. When viewed under Firefox 1.0.5 on Linux, highlighting and pasting (into a text editor) the <pre> tag listing will preserve formatting (white space and line feeds). However, this is not true when doing the same with the <code> tag listing (it will all be pasted on one line with multiple successive spaces treated as a single space) despite the fact that...
8
3807
by: Jarno Suni not | last post by:
It seems to be invalid in HTML 4.01, but valid in XHTML 1.0. Why is there the difference? Can that pose a problem when such a XHTML document is served as text/html?
23
3653
by: Xah Lee | last post by:
The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations Xah Lee, 2006-03-15 Let me summarize: The LISP notation, is a functional notation, and is not a so-called pre-fix notation or algebraic notation. Algebraic notations have the concept of operators, meaning, symbols placed around arguments. In algebraic in-fix notation, different
0
9600
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10628
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10374
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10113
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7651
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6880
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5685
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4331
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.