View Full Version : mysql store calculation
11-04-2011, 05:07 PM
I'm trying to do what seems like a simple task on the surface.
is it possible to store calculations in mysql and run them later on?
for example if I had a field with " 1 + 1 "
how could I execute that and have it return "2" ?
11-04-2011, 05:12 PM
Why not just write an if statement, as well as a form so when a user enters 1 + 1 it echoes two?
11-04-2011, 05:16 PM
let me explain a little more, though I'm thinking this is actually a php issue, not mysql.
what I need to do is store mathematical equations like this:
"GST * ( QST * AMT / 100 ) / 100"
i then run a function on it to replace some of the string values with numbers. like this:
"4.82 * ( 8.55 * 15 / 100 ) / 100"
it prints out as a string, but how can I now execute this?
11-04-2011, 05:26 PM
Ok, i got it. this should have been in the php forum.
answer is to use eval().
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.