RE: [PHP-DB] Re: Handling database calculations with a php page
Thankyou :) --- Bastien Koert [EMAIL PROTECTED] wrote: Yes, the 'a' value can also be a table alias name. Bastien From: JeRRy [EMAIL PROTECTED] To: php-db@lists.php.net Subject: [PHP-DB] Re: Handling database calculations with a php page Date: Mon, 14 Mar 2005 19:46:46 +1100 (EST) Hi, So in other words when we are talking queries anything before a . for SELECT etc means table name and after the . means column name within that table? So... (table_name).(Column_name) ? Is that right? J 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 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
Re: [PHP-DB] Re: Handling database calculations with a php page
That's the convention. You HAVE TO: - read and use the manual, the rest of us do - dig out and follow a tutorial on working with PHP and databases If you do not, you will have no real knowledge of what you're doing, only a piecemeal Someone said to do it this way. Do this BEFORE you get too deeply into your project. I'd also recommend that you Google for tutorial database normalization and take to heart what you read on normalization. It is v. simple, usually one of the early chapters of almost any book on databases, but will keep your project and structure on focus. Future queries of this nature will be answered: RTFM, 'cause you have to. If you are just starting in on this, and about to say But I don't know what questions to ask, or how to ask, that's why it is strongly recommended you dig out a tutorial and work through it, break the provided code and see what happens - error codes, etc., how fixing it works, and so forth. These are NECESSARY first steps. You *cannot* skip the basics. I can *promise* you these results: 1. The fuzzy maze of functions, use of symbols, obscurity, and the seeming magic will disappear and be replaced by confidence and the ability to ask sound questions. 2. You will point to your completed pages glowing on on monitor and proudly proclaim I did that! Wanna know how it works? (At which point your companion's eyes will glaze over and you will look like the magic-wielding wizard.) Cheers - Miles At 04:46 AM 3/14/2005, JeRRy wrote: Hi, So in other words when we are talking queries anything before a . for SELECT etc means table name and after the . means column name within that table? So... (table_name).(Column_name) ? Is that right? J 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
RE: [PHP-DB] Re: Handling database calculations with a php page
Yes, the 'a' value can also be a table alias name. Bastien From: JeRRy [EMAIL PROTECTED] To: php-db@lists.php.net Subject: [PHP-DB] Re: Handling database calculations with a php page Date: Mon, 14 Mar 2005 19:46:46 +1100 (EST) Hi, So in other words when we are talking queries anything before a . for SELECT etc means table name and after the . means column name within that table? So... (table_name).(Column_name) ? Is that right? J 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
Re: [PHP-DB] Re: Handling database calculations with a php page
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