Jump to content

custom stats


md82

Recommended Posts

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

Link to comment
Share on other sites

  • Administrators

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;

Link to comment
Share on other sites

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 !!

Link to comment
Share on other sites

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 !

Link to comment
Share on other sites

  • Administrators

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.

Link to comment
Share on other sites

  • Administrators

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>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • Administrators

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.

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...