Jump to content

How to say "Nothing has filied"


Kyle

Recommended Posts

  • Moderators

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!

Link to comment
Share on other sites

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?

  • Like 2
Link to comment
Share on other sites

  • Moderators

Tempted by teh +1 Rep :lol:

<?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.

  • Like 1
Link to comment
Share on other sites

  • Moderators

Ok, nice work guys :D

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.

Link to comment
Share on other sites

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;

       }

?>

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...