Kairon Posted October 13, 2010 Report Share Posted October 13, 2010 Hello I wonder if you can have the information of total miles flown by a pilot to put in the Pilot Center. Quote Link to comment Share on other sites More sharing options...
Kairon Posted October 14, 2010 Author Report Share Posted October 14, 2010 Help!! Quote Link to comment Share on other sites More sharing options...
Jeff Posted September 9, 2011 Report Share Posted September 9, 2011 [bump] Quote Link to comment Share on other sites More sharing options...
Guest lorathon Posted September 9, 2011 Report Share Posted September 9, 2011 In whatever query for the pireps you are using you need to add the following SUM(distance) as totalmiles Example - (NOT TESTED!) public static function getPilotInfoWithTotalDistance($pilotid) { $sql = 'SELECT p.*, u.*, SUM(p.distance) as totalmiles FROM '.TABLE_PREFIX.'pireps p LEFT JOIN '.TABLE_PREFIX.'pilots u ON u.pilotid = p.pilotid WHERE p.pilotid = '.$pilotid ; $ret = DB::get_row($sql); return $ret; } Quote Link to comment Share on other sites More sharing options...
Jeff Posted September 9, 2011 Report Share Posted September 9, 2011 I'm trying to place the code to have it show in the profile_main.tpl with the rest of the pilot information about the member. I am trying to figure out which call to use for it. This isn't working: <li><strong>Miles Flown: </strong><?php echo $userinfo->totalmiles; ?></li> I'm sure the code you just gave, goes in the PilotData.php, but trying to figure the pull code. Quote Link to comment Share on other sites More sharing options...
Guest lorathon Posted September 9, 2011 Report Share Posted September 9, 2011 Actaully the code I gave should be places in a data file. Lets call it CUSTOMData.class.php. This file would go into the core/common folder. The file would have the contents of..... <?php class CUSTOMData extends CodonData { public static function getPilotInfoWithTotalDistance($pilotid) { $sql = 'SELECT p.*, u.*, SUM(p.distance) as totalmiles FROM '.TABLE_PREFIX.'pireps p LEFT JOIN '.TABLE_PREFIX.'pilots u ON u.pilotid = p.pilotid WHERE p.pilotid = '.$pilotid ; $ret = DB::get_row($sql); return $ret; } } From the profile_main.tpl you would call as such...... <?php $custom_info = CUSTOMData::getPilotInfoWithTotalDistance($userinfo->pilotid); echo 'Total Flown Miles: '.$custom_info->totalmiles; ?> Now I havent actually tested the function but it should work. Quote Link to comment Share on other sites More sharing options...
Jeff Posted September 9, 2011 Report Share Posted September 9, 2011 Actually you did a great job on it. It works perfectly now. Thanks a lot on the help. Other interested parties wondering how to do it, follow Jeffrey's examples then in the profile_main.tpl place this in the lineup: <li><?php $custom_info = CUSTOMData::getPilotInfoWithTotalDistance($userinfo->pilotid); echo '<strong>Total Flown Miles: </strong>'.$custom_info->totalmiles; ?></li> The same exact code above will also work in the pilot_public_profile.tpl without any modifications. Quote Link to comment Share on other sites More sharing options...
AGuyFawkesMask Posted January 26, 2012 Report Share Posted January 26, 2012 Sorry to bump this, but you did a great job with this, Jeffery. Really helps me out a lot, too. Thanks. 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.