Hello,
I have 2 tables and I'm trying to do a simple calculation from one to the other. The results table will hold the calculation of lbs_per_m, or Pounds per 1,000. The part_weight field is from the quoting table and the math is; part_weight * 1000 / 16. This (I thought worked just fine earlier) but now, I cannot get this calculation to work between the 2 tables, or any of the other Parent Child tables for that matter...
In this case, the Parent Table is quoting, and the Child Table is results.
Attached are screen shots of my code. Please help!
Much appreciated,
David
Calculate between 2 Tables
-
- Veteran Member
- Posts: 101
- Joined: 2019-05-26 18:38
Calculate between 2 Tables
- Attachments
-
- Trying to streamline update
- ajax-quoting-part_weight.PNG (23.62 KiB) Viewed 1813 times
-
- Parent Table
- quoting_table.PNG (241.18 KiB) Viewed 1813 times
-
- Child Table
- results_table.PNG (178.92 KiB) Viewed 1813 times
-
- Trying to streamline update
- results-dv-js.PNG (38.97 KiB) Viewed 1813 times
-
- Calculation File
- ResultsPHP.PNG (27.62 KiB) Viewed 1813 times
Re: Calculate between 2 Tables
Hi,
can you replace in your results.php file the $data['part_weight'] with $data['quoting_ID']
Also I do not understand what you try to do in the results-dv-js. To me there seems to be no part_weight in that table.
can you replace in your results.php file the $data['part_weight'] with $data['quoting_ID']
Also I do not understand what you try to do in the results-dv-js. To me there seems to be no part_weight in that table.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
-
- Veteran Member
- Posts: 101
- Joined: 2019-05-26 18:38
Re: Calculate between 2 Tables
Wow, you are quick and good! That fixed the calculation in the results.php, and yes you are right (Sorry, I'm a newbie at this) about the results-dv.js. I think that I need to replace the part_weight with the lbs_per_m in the results table, correct?
Thanks so much for the quick reply and solution!
David
Thanks so much for the quick reply and solution!
David
Re: Calculate between 2 Tables
Hi,
well it depends what you try to acheive . I guess you wan to display the calculated lbs_per_m when the user changes the quoting_ID.
In that case you need to adjust you sql statement in the ajax-quoting-part_weight.php to give you the calculated value. Now you just retrieve the value.
Also you might review your setting. You set the lbs_per_m value via the javascript. In the before_insert / before_update you recalculate the same value and overwrite the value that should be already there. So the second part would not be needed to my opinion.
well it depends what you try to acheive . I guess you wan to display the calculated lbs_per_m when the user changes the quoting_ID.
In that case you need to adjust you sql statement in the ajax-quoting-part_weight.php to give you the calculated value. Now you just retrieve the value.
Also you might review your setting. You set the lbs_per_m value via the javascript. In the before_insert / before_update you recalculate the same value and overwrite the value that should be already there. So the second part would not be needed to my opinion.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
-
- Veteran Member
- Posts: 101
- Joined: 2019-05-26 18:38
Re: Calculate between 2 Tables
Apologies, in the above reply I meant to say replace the part_weight with lbs_per_m in the results-dv.js file, not results table.pböttcher wrote: ↑2019-06-17 16:02Hi,
well it depends what you try to acheive . I guess you wan to display the calculated lbs_per_m when the user changes the quoting_ID.
In that case you need to adjust you sql statement in the ajax-quoting-part_weight.php to give you the calculated value. Now you just retrieve the value.
Also you might review your setting. You set the lbs_per_m value via the javascript. In the before_insert / before_update you recalculate the same value and overwrite the value that should be already there. So the second part would not be needed to my opinion.
Thanks again,
David
Awesome, I'll take a look at what you are saying. I'm sure that you are correct, and again, much appreciated!
David