This topic is locked
[SOLVED]

 An automatic Total Field

11/15/2010 9:29:29 PM
PHPRunner General questions
H
horsey_kim author

From the Edit and Add screen, I been trying to have one of the fields calculate a total.
My Table: Items
My fields: id, total_value, per_value, quantity
My Goal is that my total_value field would be calculated based on (per_value x quantity)
So I used this calculation in the before record Updated event:
$values["total_value"] = $data["per_value"]$data["quantity"];
I get error - Undefined variable: data
I also tried:
$values["total_value"] = $value["per_value"]
$value["quantity"];
I get error - Undefined variable: value
Does anyone have an idea of what I have done wrong?
Thanks,
Kim

Sergey Kornilov admin 11/15/2010

Try this:
$values["total_value"] = $values["per_value"]*$values["quantity"];

H
horsey_kim author 11/15/2010

Did not work, still nothing showing up in the total_value field. I made sure I had values and not value. I also put it in the before record updated event.
I am working off an existing database that was not created by phprunner. Do you think because they defined the key ID field as mediumint instead of int, might be causing some of the issues?
I also created another phprunner folder on my server and used v5.2 to see if it maybe was a version issue, but it does the same thing in both versions.
I do have "ID" field marked as a key id field in the "pages" screen.
The below fields are defined as such in the database. We are talking dollar values so obviously I am going to need 2 places after a decimal.
quantity = int

total_value = decimal (size 9, scale 2)

per_value = decimals (size 9, scale 2)

H
horsey_kim author 11/15/2010

Okay I just created a totally separate table with phprunner and added the same fields. Then put $values["total_value"] = $values["per_value"]$values["quantity"]; in the before record updated and it still does not work. So I guess I can rule out that it is the way the fields are set up.
Any other ideas on how to get $values["total_value"] = $values["per_value"]
$values["quantity"]; to work?

Sergey Kornilov admin 11/16/2010

Kim,
you can post your application to Demo Account and open a ticket at http://support.xlinesoft.com sending your Demo Account URL. 'Demo Account' button can be found on the last screen in the program.
We'll take a look and find what exactly is wrong.

H
horsey_kim author 11/18/2010

I have open a ticket 1162671 - that has url, user and password
Thank you for taking a look to see why the before record update calculation is not working.

H
horsey_kim author 11/22/2010

Solved - It was me!! Thanks Support. I had a space in the field and did not realize it. Thanks so much! I fixed and it works great!