Jump to content

statistics [SOLVED]


airmermaid

Recommended Posts

Hi all,

I have a question regarding statistics.

With the help of Michael I was able to get Pax and Cargo shown seperately.

The code was :

$query="SELECT SUM(`load`) as totalpax FROM `phpvms_pireps` WHERE `flighttype`='P'";

$result=DB::get_results($query);

echo $result[0]->totalpax;

Now I am trying to make something different (as usual I can't :P). In my very simple logic I get total Pax Scheduled flights with the code above, then I get total Pax Charter changing flighttype as "H". Now the confusing part (for me) comes;

how do I sum both to get total pax carried?

Total Pax Carried = Total Pax Scheduled + Total Pax Charter

What I have done was (OK don't laugh...kidding.. you can laugh as loud as you can :D )

$queryP="SELECT SUM(`load`) as totalpax FROM `phpvms_pireps` WHERE `flighttype`='P'";

$resultP=DB::get_results($queryP);

$queryH="SELECT SUM(`load`) as totalpax FROM `phpvms_pireps` WHERE `flighttype`='H'";

$resultH=DB::get_results($queryH);

$total=$resultH + $resultP;

echo $total[0]->totalpax;

Cheers,

Arslan

Link to comment
Share on other sites

$queryP="SELECT SUM(`load`) as totalpax FROM `phpvms_pireps` WHERE `flighttype`='P'";
$resultP=DB::get_results($queryP);

$queryH="SELECT SUM(`load`) as totalpax FROM `phpvms_pireps` WHERE `flighttype`='H'";
$resultH=DB::get_results($queryH);

$total=$resultH[0]->totalpax + $resultP[0]->totalpax;

echo $total

I don't remember what you were doing with this, but if you're not using the results for anything but just to get the totals, you can eliminate one of the queries:

$query="SELECT SUM(`load`) as totalpax FROM `phpvms_pireps` WHERE `flighttype`='P' OR `flighttype`='H'";
$result=DB::get_results($query);
$total=$result[0]->totalpax;

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...