jb123 Posted April 17, 2017 Report Share Posted April 17, 2017 Hi, I'm trying to create a Fuel Rate indicator for my VA, but I'm not an expert on PHP, can someone help? I already have each pirep report showing what I called the Fuel Rate (the idea is to have a value that demonstrates, for each flight, the percentage of fuel spent in relation to what was initially foreseen by the VA for that given flight). I did it this way: <?php $fuelrate = substr(($pirep->routefuel - $pirep->fuelused) * 100 / $pirep->routefuel, 0, 4); echo $fuelrate?> % (routefuel is a new column I created in the 'schedules' DB). This is running fine, showing in each pirep report. What I want is to have the average of this Fuel Rate per each pilot, considering all his flights. And I'd like to show it at the pilot's public profile. Can somebody help? Thanks. Joao Quote Link to comment Share on other sites More sharing options...
CedGauche Posted April 18, 2017 Report Share Posted April 18, 2017 just use the avg sql statement: https://www.w3schools.com/sql/sql_func_avg.asp Quote Link to comment Share on other sites More sharing options...
jb123 Posted April 18, 2017 Author Report Share Posted April 18, 2017 Thanks CedGauche, but it doesn't work. I believe is because I'm not looking for an average value of a given column. I don't have a column to get the average from. What I have is 2 columns from different tables that I need to apply a formula ($pirep->routefuel - $pirep->fuelused) * 100 / $pirep->routefuel). And only then calculate the average of that formula's result. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.