CalcBuilder Forum

Multiple matrices

User jvanmid 2015-02-28 21:47:56

Hello, I want to make a price calculator for my homepage. Price depends on three variables (length, width and material). Because I have four types of material, I made four matrices. Potential buyers can choose material by an option field. Variable of option field is $material. Depending on the material I want to select a price in one of the four matrices. I use the following code, but does not work: $price=$material. It does not work because the variable of the four matrices is not 'material' but 'wood', 'steel' etcetera (the type of material the customers can choose). Is it possible to make this work this way? Or is there another (simple) option? Thanks!

Update 1-3-2015: I tried to use the switch PHP code and it seems to work out for me.

Edited by jvanmid - 01.03.2015 11:46

Moonsoft support 2015-03-02 08:13:17

Hello,
great it worked, thanks for sharing. In case it may help others, for this situation you can use the if/else structure, the switch structure, or the $$ operator. Its used to refer a variable whose name is also a variable like it happens for this case, so you could use:

$mymatrix=$$material;

and then query $mymatrix


$price=$mymatrix

Regards

...
List Manager

Build different lists for your site

Buy now!
...
Support/development 10 hours

Get a bigger amount of hours for more complex tasks and get a 10% discount

Buy now!