Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Wednesday, November 11, 2026
About Us
Magazine
Open Source
CVS
Services
Index  »  Projects  »  phpMyEdit  »  Forum  »  Field Calculations

phpMyEdit General     Field Calculations
Post new topic   Reply to topic    
 
daejin     Joined: 13 May 2005   Posts: 3  
Post Posted: 2005-05-13 05:23
Back to top  Reply with quote     

Hi folks, could anyone tell me how to do this properly? I looked through the forums for some examples and the documentation but it isn't clear. I tried the [sql] function to try and add up each row and come out with a with a calculation in the last field, but alas i have failed. Mysql comes back with a error not recognizing some of the basic calculations that can be done within itself. I run version 4.0.18. Can someone make a suggestion on another solution, in php or otherwise, that can do this?

Thanks in Advance.

 
ajh     Joined: 17 Dec 2003   Posts: 236  
Post Posted: 2005-05-13 09:55
Back to top  Reply with quote     

It would help if you could post an example of what you are trying to do.

But in principle it works like this...

Let's say you have two columns in your table: F1 and F2 (both INTEGERs).

You would like to have a read-only field called "Sum" on your screen, so what you would define is something like...

Code:
$opts['fdd']['Sum'] = array(
  'name'     => 'Sum',
  'select'   => 'T',
  'sql'      => 'SELECT F1 + F2 FROM PMEtable0'
);


Note that PME always aliases the table as PMEtable0.

 
daejin     Joined: 13 May 2005   Posts: 3  
Post Posted: 2005-05-13 17:06
Back to top  Reply with quote     

Okay this is what ive been trying i have right now.

$opts['fdd']['sum'] = array(
'name' => 'sum',
'select' => 'N',
'sql' => 'SELECT quantity * price FROM PMEtable0'
);

As the last field in table, which corresponds to the sql field which is empty at the moment. quantity is the quantity of one field, numeric(bigint32) as well as price(bigint32).

The error i get is.

MySQL error 1064

You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT quantity * price FROM PMEtable0 AS qf5 FROM forsale AS P** rest os cut off, then below that is the actual command

SELECT PMEtable0.id AS qf0,PMEtable0.Item AS qf1,PMEtable0.quantity AS qf2,PMEtable0.price AS qf3,PMEtable0.total AS qf4,SELECT quantity * price FROM PMEtable0 AS qf5 FROM forsale AS PMEtable0 ORDER BY PMEtable0.id LIMIT 0,-15.992 miliseconds

Am i forgetting something simple? or is SQL just spitting it back because it doesn't like something in how its setup?

Thanks

 
ajh     Joined: 17 Dec 2003   Posts: 236  
Post Posted: 2005-05-14 16:07
Back to top  Reply with quote     

No - you have an error because of course I was talking rubbish!!! Sorry!

Your SQL line should read:
Code:

'sql' => 'quantity * price'


 
daejin     Joined: 13 May 2005   Posts: 3  
Post Posted: 2005-05-14 21:52
Back to top  Reply with quote     

thanks it worked like a charm. Not to keep buggin you but any easy way to add up the sums of all rows and make one final total? its not really important just wondering if its do-able.

 
ajh     Joined: 17 Dec 2003   Posts: 236  
Post Posted: 2005-05-15 08:53
Back to top  Reply with quote     

As far as I'm aware, this isn't do-able unfortunately.

 
Post new topic   Reply to topic    

Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top · Feedback form · Application form
Report bug on PLATON.SK website · Terms of use · Privacy policy