I want to automate the calculation of percentages of pass/fail columns from my tables. What I have done up to now is to use
$query = mysqli_query(
$con,
"SELECT column_name FROM information_schema.columns WHERE TABLE_NAME='door1'"
);
in order to get all the column names and then
$x=mysqli_query(
$con,
"SELECT 100 * SUM($b ='$a')/COUNT($b) AS total FROM door1"
);
to calculate the percentages. Certain columns are not pass/fail but include other information that is irrelevant to this.
I want for those columns to print N/A instead of 0%. I thought of changing the data type of the pass fail columns to something else and run the above only for them but I am not sure how to do that. These columns that are different change from table to table so I don't want to write out all of the columns I want or don't want. Any ideas?