HighFlyerPL185 Posted March 30, 2013 Report Posted March 30, 2013 Hi there, I'm trying to print the aircraft's full name, but the array comes out as NULL. Any ideas? $aircraft = OperationsData::getAircraftInfo($pirep->aircraft); <?php echo $aircraft->fullname; ?> If I do var_dump($aircraft); it comes out as NULL. $pirep is taken from a foreach($pireps as $pirep). I'm trying to parse it in frontpage_main.tpl. Quote
Sava Posted March 30, 2013 Report Posted March 30, 2013 It might be that $pirep->aircraft is empty. Try doing a var_dump on that. Quote
HighFlyerPL185 Posted March 30, 2013 Author Report Posted March 30, 2013 It might be that $pirep->aircraft is empty. Try doing a var_dump on that. Doesn't look like it's empty. It returned 'B738'. Bizarre. Quote
mseiwald Posted March 30, 2013 Report Posted March 30, 2013 $pirep->aircraft Should return the aircraft ID.... not the aircraft ICAO. Quote
freshJet Posted March 30, 2013 Report Posted March 30, 2013 Yes this will return the ID, however it should still work. Quote
Sava Posted March 31, 2013 Report Posted March 31, 2013 The fact is that $pirep->aicraft contains the ICAO not the ID in the table so the end query looks smth like ".... WHERE `id`='B738'" which returns an empty object/array. You need to pass the aircraft ID, not the ICAO. Quote
Moderators Parkho Posted April 2, 2013 Moderators Report Posted April 2, 2013 PIREPS report aircraft ID in the table, so add the following to your "OperationsData.class.php": public function GetAircraftById($id) { $sql="SELECT * FROM phpvms_aircraft WHERE id='$id' "; return DB::get_row($sql); } And: $aircraft = OperationsData::GetAircraftById($pirep->aircraft); <?php echo $aircraft->fullname; ?> This will give you aircraft full name. 1 Quote
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.