Dynamic calculations

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Remos
Forum Newbie
Posts: 3
Joined: Wed Jun 03, 2009 1:00 am

Dynamic calculations

Post by Remos »

Hi everyone,
I'm new of this Forum.
Maybe my question could be unusual. I'm designing an application to manage a budgeting.
I'd like the user could set calculations up for most of data in the web pages.
Something like he did, for a long time, with excel spreadsheets.
Have you got an idea to models that?

Thanx in advance.
Remo
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: Dynamic calculations

Post by Mark Baker »

If he wants to use Excel spreadsheet style calculations, then use a library such as PHPExcel with it's calculation engine to give him what he's familiar with
Remos
Forum Newbie
Posts: 3
Joined: Wed Jun 03, 2009 1:00 am

Re: Dynamic calculations

Post by Remos »

thanx Mark,
but maybe my question is more complicated:
data will not come from an excel file. That's because data are on a mysql db engine, now.
Now they work on web pages developed with php.
I'm looking for a solution to give the users tools to change some kind of calculations on their onwn making the application more flexible.
Ex.:
(before change)
sales Product a=(sales Product a + sales Product bulk a+VAT 20%)

(after change)
sales Product a=(sales Product a + VAT 20%)

I would like that my php code should be able to "catch" that changes, but I cannot find a way to describe it.
I think I need a configuration file to wrap such meta-data.

I don't know if I got it across
User avatar
Chalks
Forum Contributor
Posts: 447
Joined: Thu Jul 12, 2007 7:55 am
Location: Indiana

Re: Dynamic calculations

Post by Chalks »

I'm not entirely sure what you're asking for, but if you have a mysql database set up already, it should be fairly simple to create a form that will allow your client to input data and have the php handler manipulate the data however you need it done.

If you're unfamiliar with php/mysql manipulation, check out this tutorial
Remos
Forum Newbie
Posts: 3
Joined: Wed Jun 03, 2009 1:00 am

Re: Dynamic calculations

Post by Remos »

Chalks,
I know the php/MySQL basics and I've already developed a lot of applications.
But my intent is to find a way to let the user to change that calculation without my actions.
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: Dynamic calculations

Post by Mark Baker »

Remos wrote:thanx Mark,
but maybe my question is more complicated:
data will not come from an excel file. That's because data are on a mysql db engine, now.
Now they work on web pages developed with php.
I'm looking for a solution to give the users tools to change some kind of calculations on their onwn making the application more flexible.
I'm not suggesting that you use Excel ratheer than MySQL for data storage.
But there's nothing to stop you presenting data to the user in a data grid (a series of rows and columns), or to stop you using the Excel-style formulae that your users are already familiar with.

If you want to permit the users to enter their own formulae (whether Excel-style or otherwise) for calculations, then you'll need a calculation engine... you can write your own, or you can find a library that performs that function.
I've offered a suggestion for a library that could provide this function: but if you want to write your own, I'd suggest reading up on Reverse Polish Notation and Dijkstra's Shunting-Yard algorithm
Post Reply