custom stats

hi ! I wanna add a “online flights” stat to my airline stats section. I made a custom pirep field dropdown “flew online” with the option “yes or no”.. Is it possible to have a code that if “yes” was selected

it would add to a online flight total displayed on the front of my page ?

thanks !

[![post-643-025915700 1280051661_thumb.jpg](<fileStore.core_Attachment>/monthly_07_2010/post-643-025915700%201280051661_thumb.jpg)](<fileStore.core_Attachment>/monthly_07_2010/post-643-025915700%201280051661.jpg)

hi ! I wanna add a “online flights” stat to my airline stats section. I made a custom pirep field dropdown “flew online” with the option “yes or no”.. Is it possible to have a code that if “yes” was selected

it would add to a online flight total displayed on the front of my page ?

thanks !

Build a class with a sql call something like ->

<?php

   function get_onlineflights() {

   $query = "SELECT COUNT(*)AS total FROM '.TABLE_PREFIX.'pirepvalues WHERE value = 'Yes'";

   return DB::get_row($query); 

   }
?>

then in your template call it like this ->

$total = mynewdata.class::get_onlineflights();
echo $total->total;

awesome ! except didnt quite get it working.

what do I put this code inside of ?

$total = mynewdata.class::get_onlineflights();

echo $total->total;

the existing codes look like

<strong>Total Flights Today: </strong><?php echo StatsData::totalflightstoday(); ?><br>

thanks !!

<?php $total = mynewdata::get_onlineflights(); ?>
<strong>Total Flights Flown On Vatsim: </strong><?php echo $total->total; ?><br>

Where should I put this code:

<?php

function get_onlineflights() {

$query = “SELECT COUNT(*)AS total FROM '.TABLE_PREFIX.'pirepvalues WHERE value = ‘Yes’”;

return DB::get_row($query);

}

?>

I’ve tried a few different places but cant figure it out..

thanks as always !

You need to create a new class or include it in an existing one, but if you include it in an existing one it will be overwritten in an update of the system. Then when you call it from our module or template (module preferably) you change the

mynewdata.class

with whatever you name you class.

I’m lost.. So I make a “class” in the /core/classes folder or where ? I apologize im such a noob

Create a file called vatsimflightsData.class.php in your core/common folder and put this in it ->

<?php
   class vatsimflightsData extends CodonData {

       function get_onlineflights() {

         $query = "SELECT COUNT(*)AS total FROM '.TABLE_PREFIX.'pirepvalues WHERE value = 'Yes'";

       return DB::get_row($query); 

       }
}
?>

Then in a template do ->

<?php $total = vatsimflightsData::get_onlineflights(); ?> 
<strong>Total Flights Flown On Vatsim: </strong><?php echo $total->total; ?><br>

Thats a lot better- No errors when I go to that page- but the numbers aren’t showing up..

Total Aircraft: 52

Total Flights Flown: 2

Total Flights Flown On Vatsim:

Total Hours Flown: 9.10

Passengers Carried: 235

Fuel Burned (lbs.): 24777

I really appreciate the help

Try a

<?php print_r($total); ?>

after the data call and see what it pukes out. if it empty something in the db call is not correct, I use the screenshot in the first post to write the call, so if something in your db is different than that it will not work.

is the “field id” relevant ? I noticed the fieldid for the vatsim dropdown is 4. if the code only pulls (yes,no) from that fieldid could that help it ?

Did you do a print_r? what was output?

I added it, still empty.. here is a screenshot of how the database stands today, it might have changed slightly.

[![post-643-075890800 1280559294_thumb.jpg](<fileStore.core_Attachment>/monthly_07_2010/post-643-075890800%201280559294_thumb.jpg)](<fileStore.core_Attachment>/monthly_07_2010/post-643-075890800%201280559294.jpg)