Re: Re: Handling database calculations with a php page

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




First of all, check the SELECT statement in your database documentation, because you do this within your select. It is important you that you inform yourself about this, because you will use it a lot. So this is not really a PHP question. The statement is written something like this:


SELECT a.currency + b.currency + c. currency curr_total from a, b, c
WHERE a.cust_id = b.cust_id
AND b.cust_id = c.cust_id
AND c.cust_id = '$customer_id'; (or cust_id and some kind of transaction identifier)


( Tables are named a, b and c for convenience. Those who prefer JOIN syntax would write it differently)

Secondly, unless you are having problems with rounding errors or must preserve the state of an issued document, like an invoice or purchase order, why write to a 4th table? Your data is contained in a, b, and c, and queries are v. fast, so what advantage or benefit is derived from storing the results in "d"?

If you must do it, then you use either an INSERT or UPDATE statement, with appropriate customer and transaction IDs to keep things straight.

If you do not know how to use/write the PHP code to execute this, examine the mysql functions in the PHP docs and avail yourself of the numerous tutorials on the Web. Google for something like "tutorial PHP MySQL".

As much as possible, do the work within the database.

Hope this is helpful.

Regards - Miles

At 07:38 AM 3/13/2005, JeRRy wrote:
<snip>
> What is the best PHP code to use for this inside a
> PHP
> code?
</snip>

I meant ...

What is the best PHP code to use for this inside a PHP
page/file.

(e.g. calculate.php)

Also the total of the 3 tables should than be updated
to a 4th table which I did not mention.

So the total of table 1, 2 and 3 should than be
updated to a 4th table.

I want to keep it all seperated like this (in
different tables) so it's easier to manage and learn
from.

Thanks!

Find local movie times and trailers on Yahoo! Movies.
http://au.movies.yahoo.com

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux