md82 Posted July 25, 2010 Report Share Posted July 25, 2010 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 ! Quote Link to comment Share on other sites More sharing options...
Administrators simpilot Posted July 25, 2010 Administrators Report Share Posted July 25, 2010 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; Quote Link to comment Share on other sites More sharing options...
md82 Posted July 26, 2010 Author Report Share Posted July 26, 2010 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 !! Quote Link to comment Share on other sites More sharing options...
Administrators simpilot Posted July 26, 2010 Administrators Report Share Posted July 26, 2010 <?php $total = mynewdata::get_onlineflights(); ?> <strong>Total Flights Flown On Vatsim: </strong><?php echo $total->total; ?><br> Quote Link to comment Share on other sites More sharing options...
md82 Posted July 26, 2010 Author Report Share Posted July 26, 2010 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 ! Quote Link to comment Share on other sites More sharing options...
Administrators simpilot Posted July 26, 2010 Administrators Report Share Posted July 26, 2010 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. Quote Link to comment Share on other sites More sharing options...
md82 Posted July 26, 2010 Author Report Share Posted July 26, 2010 I'm lost.. So I make a "class" in the /core/classes folder or where ? I apologize im such a noob Quote Link to comment Share on other sites More sharing options...
Administrators simpilot Posted July 26, 2010 Administrators Report Share Posted July 26, 2010 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> Quote Link to comment Share on other sites More sharing options...
md82 Posted July 27, 2010 Author Report Share Posted July 27, 2010 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 Quote Link to comment Share on other sites More sharing options...
Administrators simpilot Posted July 28, 2010 Administrators Report Share Posted July 28, 2010 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. Quote Link to comment Share on other sites More sharing options...
md82 Posted July 28, 2010 Author Report Share Posted July 28, 2010 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 ? Quote Link to comment Share on other sites More sharing options...
Administrators simpilot Posted July 28, 2010 Administrators Report Share Posted July 28, 2010 Did you do a print_r? what was output? Quote Link to comment Share on other sites More sharing options...
md82 Posted July 31, 2010 Author Report Share Posted July 31, 2010 I added it, still empty.. here is a screenshot of how the database stands today, it might have changed slightly. 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.