Forum


Calc Builder Support

Calc Builder support
Forums
No se permite escribir sin estar logado. Por favor, login

Question about a table 31.05.2017 16:06

Hello,

I have the following issue.

I have two fields which gave a result = $result. This result is a number (example 1000)

I have a table with different prices and based on the value from $result I want to show the right price.

Example $table

$result = till 100 price = 50
$result = between 100 en 300 price = 150
$result = between 300 and 500 price = 250
etc.

I have tested with a matrix but can't show the right price. It shows nothing when i place this in the code: $pricetoshow= $table[$result]["price"]

Of course I set $pricetoshow in the exit layout.

How can I do this?
Thanks

Edited by moon_1108 - 31.05.2017 16:10

Re: Question about a table 31.05.2017 17:13

Hi,
the matrix is intended to get a specific cell given the 2 search values (row,column), so you have different options here, if you don't want to create a huge matrix with all possible values :

1
2
3
..
100
101
102
...

which would give you the right result but it would be a great task to create and maintain. We suggest to create your table with different options, following your example:

price
till100 50
100-300 150
300-500 250


and at the code, introduce a condition to get the proper row key for each case:


//calculate $result


//generate the right key
if($result[100){
$tablekey="till100";
}

if($result]100 && $result[=300){
$tablekey="100-300";
}

if($result]300 && $result[=500){
$tablekey="300-500";
}

..etc
//Now you can get the proper price using $tablekey

$pricetoshow=$table[$tablekey]["price"];

Of course you should replace on the above the [ and ] for lower than and greater than symbols, they are stripped by the forum rules.

This should do the work, please let us know if you need further help.

Edited by MSTeam - 31.05.2017 17:16
Moonsoft Team
www.moonsoft.es

Re: Question about a table 31.05.2017 22:06

Hello,

Thank you very much for the good and quick answer. I think its nearly good. But it won't work complete. This is what I did:

Table variable = $tableopp with one column = "oppervlakte"

first item till100 has 780 as price value
second item 100-300 has 805 as price value
third item 300-500 has 900 as price value

I have two fields for the sum: $kas and $buitenteelt (last is multiply with 0.25). Together they are $result.
This is the code:

$result=$kas+($buitenteelt*0.25);
//calculate $result

//generate the right key
if($result{100){
$tablekey="till100";
}

if($result{100 && $result}=300){
$tablekey="100-300";
}

if($result{300 && $result}=500){
$tablekey="300-500";
}
$pricetoshow=$tableopp[$tablekey]["price"];

(I also changed the greater and lower than symbols in this forum)

And this is exit layout:
bedrag.... ##result##
price.... ##pricetoshow##

But the pricetoshow is not in the results?


Hope you can help me further.

Thans


Edited by moon_1108 - 31.05.2017 22:08

Edited by moon_1108 - 31.05.2017 22:10

Edited by moon_1108 - 01.06.2017 13:37

Re: Question about a table 01.06.2017 09:06

Hello,
we assume if that your column is called 'oppervlakte' you used to recover values:

$pricetoshow=$tableopp[$tablekey]["oppervlakte"];

instead of 'price' we had at the example. We suggest to check this, and also to print on your result section the intermediate results that will guide you to the point where your result is empty. We'd print

##result##

in order to find out if your search value is valid.

##tablekey##

so you will see if you're getting a valid row reference with conditional expressions.


If you can't get it working please export your calculator, zip it and create a new ticket at your helpdesk and attach it there. We'd take a quick look and let you know how to correct. At the helpdesk we can also share code without restrictions.

Thanks, regards
Moonsoft Team
www.moonsoft.es

Re: Question about a table 01.06.2017 13:37

Hello,

It won't work for me. I did send you a ticket with my calculator.

Thanks.
Are you satisfied with our products/services/support?
Please help us to keep improving, add a review at  joomla extensions site and  magento connect
FaLang translation system by Faboba

Lo que nuestros clientes opinan de nosotros