flyalaska Posted August 20, 2011 Report Share Posted August 20, 2011 Looking at my Top Landing, the top 10 which is displayed on the index page. It has a few -1 and the rest are -2's. Is there a way to display the top 10 for the currant month rather than overall? Quote Link to comment Share on other sites More sharing options...
Administrators simpilot Posted August 20, 2011 Administrators Report Share Posted August 20, 2011 I think this may be what you are looking for -> http://forum.phpvms.net/topic/2989-touchdownstats-10/page__view__findpost__p__21408 Quote Link to comment Share on other sites More sharing options...
flyalaska Posted August 20, 2011 Author Report Share Posted August 20, 2011 Tried that really screwed up my page. Here is the section of the code of TouchdownStatsData.class. The month section is at the bottom public function get_all_stats() { $query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps` WHERE landingrate < '0' ORDER BY landingrate DESC"; return DB::get_results($query); } public function get_stats($howmany) { $query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps` WHERE landingrate < '0' ORDER BY landingrate DESC LIMIT $howmany"; return DB::get_results($query); } public function get_pilot_landingstats($pilotid, $howmany) { $query = "SELECT * FROM `".TABLE_PREFIX."pireps` WHERE landingrate < '0' AND pilotid = '$pilotid' ORDER BY landingrate DESC LIMIT $howmany;"; return DB::get_results($query); } public function pilot_stats($pilotid) { $query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps` WHERE landingrate < '0' AND pilotid = '$pilotid' ORDER BY landingrate DESC"; return DB::get_results($query); } public function get_all_stats($month) { $query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps` WHERE landingrate < '0' AND MONTH(submitdate) = '$month' ORDER BY landingrate DESC"; return DB::get_results($query); } Quote Link to comment Share on other sites More sharing options...
Administrators simpilot Posted August 20, 2011 Administrators Report Share Posted August 20, 2011 There is a bracket or something missing in the file and you have the same name for two functions - get_all_stats - you need to rename one of them to something different but I can not see what you have missing without seeing the entire file. It could be a } or a ; missing somewhere above line 23. Quote Link to comment Share on other sites More sharing options...
flyalaska Posted August 20, 2011 Author Report Share Posted August 20, 2011 Line 23 is the closing bracket for the month section. Here is the whole code. I looked and everything seems to match with the others. <?php //simpilotgroup addon module for phpVMS virtual airline system // //simpilotgroup addon modules are licenced under the following license: //Creative Commons Attribution Non-commercial Share Alike (by-nc-sa) //To view full license text visit http://creativecommons.org/licenses/by-nc-sa/3.0/ // //@author David Clark (simpilot) //@copyright Copyright (c) 2009-2010, David Clark //@license http://creativecommons.org/licenses/by-nc-sa/3.0/ class TouchdownStatsData extends CodonData { public function get_all_stats($month) { $query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps` WHERE landingrate < '0' AND MONTH(submitdate) = '$month' ORDER BY landingrate DESC"; return DB::get_results($query); } public function get_all_stats() { $query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps` WHERE landingrate < '0' ORDER BY landingrate DESC"; return DB::get_results($query); } public function get_stats($howmany) { $query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps` WHERE landingrate < '0' ORDER BY landingrate DESC LIMIT $howmany"; return DB::get_results($query); } public function get_pilot_landingstats($pilotid, $howmany) { $query = "SELECT * FROM `".TABLE_PREFIX."pireps` WHERE landingrate < '0' AND pilotid = '$pilotid' ORDER BY landingrate DESC LIMIT $howmany;"; return DB::get_results($query); } public function pilot_stats($pilotid) { $query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps` WHERE landingrate < '0' AND pilotid = '$pilotid' ORDER BY landingrate DESC"; return DB::get_results($query); } public function pilot_average($pilotid) { $stats = self::pilot_stats($pilotid); $total = 0; $count = 0; foreach ($stats as $stat) { $total = $total + $stat->landingrate; $count++; } $average = $total / $count; return $average; } public function airline_average() { $stats = self::get_all_stats(); $total = 0; $count = 0; foreach ($stats as $stat) { $total = $total + $stat->landingrate; $count++; } $average = $total / $count; return $average; } } Fatal error: Cannot redeclare TouchdownStatsData::get_all_stats() in /home/caspsh1/public_html/fly/core/common/TouchdownStatsData.class.php on line 25 Quote Link to comment Share on other sites More sharing options...
Administrators simpilot Posted August 20, 2011 Administrators Report Share Posted August 20, 2011 Fatal error: Cannot redeclare TouchdownStatsData::get_all_stats() in /home/caspsh1/public_html/fly/core/common/TouchdownStatsData.class.php on line 25 You need to rename one of the two occurances of get_all_stats 1 Quote Link to comment Share on other sites More sharing options...
flyalaska Posted August 20, 2011 Author Report Share Posted August 20, 2011 Got it without any errors now. Shouldn't this show the top 10 for the month? <?php MainController::Run('TouchdownStats', 'top_landing_this_month', '10'); ?> Quote Link to comment Share on other sites More sharing options...
Administrators simpilot Posted August 21, 2011 Administrators Report Share Posted August 21, 2011 Thats going to try to pull from the controller, I am not sure how you have done it but if you just have it in the data model you can get the info direct from there; $data = TouchdownStatsData::top_landing_this_month('10'); Your function in the data model should look something like this if you after 10 records from the current month; public function top_landing_this_month($howmany) { $today = getdate(); $month = $today[mon]; $year = $today[year]; $query = "SELECT * FROM phpvms_pireps WHERE landingrate <'0' AND MONTH(submitdate) = '$month' AND YEAR(submitdate) = '$year' ORDER BY landingrate DESC LIMIT $howmany;"; return DB::get_results($query); } 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.