I need some help with doing some calculations using the values from two different records.

3 posts by 2 authors in: Forums > CMS Builder
Last Post: March 20, 2025   (RSS)

By Tim - March 20, 2025

Hello kevbarker,

I believe replacing your calculation table cell with the following should do the trick. I am assuming you just need it for the display and not in the database. 

<td align="center"><?php echo htmlencode( (intval($record['total_live_hatchlings']) / intval($record['total_number_of_eggs'])) * 100 ) ?></td>

So here we are taking each record column, converting them to integers, divide the total hatchlings by the number of eggs and multiply by 100. That will give you a floating point value. If you need to round it, there is the PHP round function you can use to do that as well. 

Hopefully this is what you were looking to do.

Tim Hurd
Senior Web Programmer
Interactivetools.com

By kevbarker - March 20, 2025

Thank you so much!! That worked perfectly. You're a lifesaver! I added the round function as well.

Have a great day!

Kevin