dimitris Posted November 9, 2010 Report Posted November 9, 2010 Hello ! I want to display a table with the pilots forom every hub. For example i have a HUB the EDDF and i want to display only those pilots. Have someone a code for this ? 1 Quote
Administrators simpilot Posted November 9, 2010 Administrators Report Posted November 9, 2010 To collect the data you can use the existing PilotData class -> <?php $pilots = PilotData::getAllPilotsByHub('EDDF'); ?> Then you will have the $pilots variable loaded with just the pilots from EDDF and you can use it to display them in a table or whatever you would like. Quote
dimitris Posted November 10, 2010 Author Report Posted November 10, 2010 hello ! thank you simpilot i try it but no results me code is : <h3>Thessaloniki Airport (LGTS)</h3> <?php $pilots = PilotData::getAllPilotsByHub('LGTS'); ?> <table id="tabledlist" class="tablesorter" width="800" border="0"> <tr> <th>Pilot</th> <th>Country</th> <th>Rank</th> </tr> <tr> <td><?php echo ($pilots->code, $pilots->pilotid); ?></td> <td><img src="<?php echo Countries::getCountryImage($pilot->location);?>" alt="<?php echo Countries::getCountryName($pilot->location);?>" /></td> <td><img src="<?php echo $pilot->rankimage?>" alt="<?php echo $pilot->rank;?>" /></td> </tr> </table> but without any success... can you help me ? Quote
Administrators simpilot Posted November 10, 2010 Administrators Report Posted November 10, 2010 You need to break up your $pilots array with a foreach loop. You have $pilots in some places and $pilot in others. You really should have the datacall back in the controller as well, not in the template but if you are using the cms/page function I see why you are doing it this way. Try this, I just did a quick clean up but it should work, you will have to style it to exactly what you want. <h3>Thessaloniki Airport (LGTS)</h3> <?php $pilots = PilotData::getAllPilotsByHub('LGTS'); ?> <table id="tabledlist" class="tablesorter" width="800" border="0"> <tr> <th>Pilot</th> <th>Country</th> <th>Rank</th> </tr> <?php foreach ($pilots as $pilot) { ?> <tr> <td><?php echo PilotData::GetPilotCode($pilot->code, $pilot->pilotid); ?></td> <td><img src="<?php echo Countries::getCountryImage($pilot->location); ?>" alt="<?php echo Countries::getCountryName($pilot->location); ?>" /></td> <td><img src="<?php echo $pilot->rankimage ?>" alt="<?php echo $pilot->rank; ?>" /></td> </tr> <?php } ?> </table> 1 Quote
dimitris Posted November 10, 2010 Author Report Posted November 10, 2010 You need to break up your $pilots array with a foreach loop. You have $pilots in some places and $pilot in others. You really should have the datacall back in the controller as well, not in the template but if you are using the cms/page function I see why you are doing it this way. Try this, I just did a quick clean up but it should work, you will have to style it to exactly what you want. <h3>Thessaloniki Airport (LGTS)</h3> <?php $pilots = PilotData::getAllPilotsByHub('LGTS'); ?> <table id="tabledlist" class="tablesorter" width="800" border="0"> <tr> <th>Pilot</th> <th>Country</th> <th>Rank</th> </tr> <?php foreach ($pilots as $pilot) { ?> <tr> <td><?php echo PilotData::GetPilotCode($pilot->code, $pilot->pilotid); ?></td> <td><img src="<?php echo Countries::getCountryImage($pilot->location); ?>" alt="<?php echo Countries::getCountryName($pilot->location); ?>" /></td> <td><img src="<?php echo $pilot->rankimage ?>" alt="<?php echo $pilot->rank; ?>" /></td> </tr> <?php } ?> </table> You are the BEST !!!! Thank you so much !!!! working also if i want to show the pireps i can use this code ? <?php $pireps = PirepData::getAllPirepsByHub('LGTS'); ?> ? Quote
TennShadow Posted November 11, 2010 Report Posted November 11, 2010 You need to break up your $pilots array with a foreach loop. You have $pilots in some places and $pilot in others. You really should have the datacall back in the controller as well, not in the template but if you are using the cms/page function I see why you are doing it this way. Try this, I just did a quick clean up but it should work, you will have to style it to exactly what you want. <h3>Thessaloniki Airport (LGTS)</h3> <?php $pilots = PilotData::getAllPilotsByHub('LGTS'); ?> <table id="tabledlist" class="tablesorter" width="800" border="0"> <tr> <th>Pilot</th> <th>Country</th> <th>Rank</th> </tr> <?php foreach ($pilots as $pilot) { ?> <tr> <td><?php echo PilotData::GetPilotCode($pilot->code, $pilot->pilotid); ?></td> <td><img src="<?php echo Countries::getCountryImage($pilot->location); ?>" alt="<?php echo Countries::getCountryName($pilot->location); ?>" /></td> <td><img src="<?php echo $pilot->rankimage ?>" alt="<?php echo $pilot->rank; ?>" /></td> </tr> <?php } ?> </table> Thanks Simpilot! I've always wanted a dynamic Hub page but just couldn't figure it out. This has helped me at least get the ball rolling. I am also interested in having a list of the last 50 PIREPS for that hub as well as a list of 50 schedules leaving that hub. I did some research on the forums and some goolging using PirepData::getAllPirepsByHub and boy did I make a mess. LOL. I spent over an hour on different things with no luck. I have to say this is fun but I just wish I could get this to stick in my head. Anyways, thanks for getting me started on this. Keith Quote
Administrators simpilot Posted November 12, 2010 Administrators Report Posted November 12, 2010 Thanks Keith, try putting a print_r($yourvariable); right after your datacall and see what is available to you as far as field names, I believe it should be everything out of that table for PIREPS. Then you can break up the array using a foreach loop, then display what you want using echo $yourvariable->fieldname 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.