Moderators Kyle Posted February 5, 2011 Moderators Report Posted February 5, 2011 Ok, I been on that for a while and I'm trying to firgure out how can I call if there was no reports filed, then how can I say "No Reports Yet" on the Last Flights. So here's my code, and I want to add a part so if there was no flight reports, I want it to say no flights filed yet. <?php $flights = PIREPData::getLastReports($userinfo->pilotid, '10'); $string = ""; foreach($flights as $flight) { $string = $string.$flight->depicao.'+-+'.$flight->arricao.',+'; } ?> Any help would be awesome and I'll give you 1+ rep if it works. Thanks! Quote
Tom Posted February 5, 2011 Report Posted February 5, 2011 I'm not entirely sure what you're trying to achieve with $string, but providing it's correct: <? $flights = PIREPData::getLastReports($userinfo->pilotid, '10'); $string = ""; if(!$flights){ $string = 'No flights have been filed!'; } else { foreach($flights as $flight) { $string = $string.$flight->depicao.'+-+'.$flight->arricao.',+'; } } ?> Your string will end up looking like this, for example: "EGKK+-+KJFK,+KJFK+-+EGKK,+EGKK+-+KMIA,+KMIA+-+EGKK,+" and so on... If that's what you intended? 2 Quote
Moderators mark1million Posted February 5, 2011 Moderators Report Posted February 5, 2011 Tempted by teh +1 Rep <?php if(!$pireps) { echo '<p>Sorry No recent flights have been found</p></div>'; return; } $flights = PIREPData::getLastReports($userinfo->pilotid, '20'); $string = ""; foreach($flights as $flight) { $string = $string.$flight->depicao.'+-+'.$flight->arricao.',+'; } ?> You may need to get rid of that extra closing div as that is needed for me on my site. 1 Quote
Moderators Kyle Posted February 5, 2011 Author Moderators Report Posted February 5, 2011 Ok, nice work guys But It didn't work, so I'll give you the full code for the GC of if there was no reports filed. <?php $flights = PIREPData::getLastReports($userinfo->pilotid, '10'); $string = ""; foreach($flights as $flight) { $string = $string.$flight->depicao.'+-+'.$flight->arricao.',+'; } ?> <img src="http://www.gcmap.com/map?P=<?php echo $string ?>&MS=bm&MR=240&MX=650x360&PM=pemr:diamond7:red%2b%22%25I%22:red&PC=%230000ff" /><br /> Maps generated by the <a href="http://www.gcmap.com/">Great Circle Mapper</a> - copyright © <a href="http://www.kls2.com/~karl/">Karl L. Swartz</a> Thanks for the help. Quote
Tom Posted February 5, 2011 Report Posted February 5, 2011 Here try this <?php $flights = PIREPData::getLastReports($userinfo->pilotid, '10'); if(!$flights){ echo 'No flights yet!'; } else { $img = '<img src="http://www.gcmap.com/map?P='; foreach($flights as $flight){ $img.= $flight->depicao.'-'.$flight->arricao.','; } $img.= '&MS=bm&MR=240&MX=650x360&PM=pemr:diamond7:red%2b%22%25I%22:red&PC=%230000ff" /><br />Maps generated by the <a href="http://www.gcmap.com/">Great Circle Mapper</a> - copyright © <a href="http://www.kls2.com/~karl/">Karl L. Swartz</a>'; echo $img; } ?> 1 Quote
Moderators mark1million Posted February 5, 2011 Moderators Report Posted February 5, 2011 I see where your going now, i got the same with new pilots so all i did was tell that page not to output a php error <?php error_reporting(0); ?> at the top of that tpl Quote
Moderators Kyle Posted February 5, 2011 Author Moderators Report Posted February 5, 2011 Top Shot there Tom, I guess I wasn't filling the php into the GC Map. Thanks alot!!! 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.