简体   繁体   中英

Editable formulas relating variables in MYSQL

I have a project where am designing a MySQL + PHP employee evaluation system. It should provide "admin" control where the admin can change the evaluation questions, the formula to calculate final employee rating and the weight of each question.

So I need a way to save and execute a formula in MySQL dynamically that uses elements in the database. For example, if the evaluation formula is a simple average:

(Rating1 + Rating2 + Rating3) / 3  

where "Rating" is a dynamic number taken from another table/row.

The Admin should be able to view this formula and change it if needed to anything for example:

(Rating1 * 0.5 + Rating2 * 0.25 + Rating3 * 0.25) /3

So using again whatever elements available and creating an equation and saving it again in a usable form in the database.

how can this be done?

If I am getting the context, then what you need is this formula (Rating1*X + Rating2*Y + Rating3*Z)/3

EXPLANATION:

By default X, Y and Z equates to 1. If you want to overwrite the values of X, Y and Z then supply it the values using input tags using ajax.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM