Look Pared, basically, if you want to do that, is done in the program
portion of it through variables, that way every time it reads the data,
it calculates the output. If you do the math, and then save it to the
record, it might not be accurate at all times. I'm of course not an
expert, so I will await input from someone else, but I suggest you read
about variables, and math processes in the Handbook.

Plus, if you change the pricing, you don't need to recalculate your
whole inventory value, cause it is always accurate.

As I said, look in the variables, and add it to the program portion of
it.

Elliot J. Balanza
CEO
M&B Trading Co., SA de CV


-----Mensaje original-----
De: Matt [mailto:[EMAIL PROTECTED]] 
Enviado el: Sábado, 24 de Noviembre de 2001 17:55
Para: [EMAIL PROTECTED]; Jared Howard
Asunto: Re: [PHP] MySQL function in a Table's Column

> I basically want to make a column that will do math to other columns,
like
in
> a spreadsheet program.  Is it possible?  And if so, what do I look
for?
> And if you can give me an example that would be great.

No, you can't do that, you store the raw data, and do the math when you
retrieve it.  It's bad database design to store summary data (i.e. a
total
order amount vs calculating from detail lines), or data that can be
derived
within a row itself by caclulating from other fields.  The reasons are
basically that it wastes space in the db, and that the calculated values
become out of balance (and require cleanup programs/scripts to realign
them).  Sometimes one must store this type of info for efficiency
purposes,
and in those cases, the value is calculated (by you) and then stored in
the
db; but it should be avoided as much as possible because of the db
integrity
issue noted above.

In a spreadsheet it's different, right, the value isn't stored, it's
calculated when the sheet is modified.  That's what you need to do.
Retrieve
the row, calculate the value in the script, and display it.  It looks to
the
end-user like it was in the db, but only the basic info is there, such
as
qty, and unit price.  The extended price is calculated on demand as
needed
from those two basic entities.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to