Jump to content

Recommended Posts

Posted

Hello once again!

Today, I got a problem because I want to view 5 most recent flights for a pilot in the pilot_public_profile.php file.

 

this is what I tried to add, but didn’t work, I just got a emty Array of the flights:

<?php echo PIREPData::getLastReports($pilot->pilotid, 5, PIREP_ACCEPTED);

The $pilot variable is the variable that is Main used in the file.

Posted

Could be your id code id wrong. Can you check what result it is giving by using this

 

<?php echo json_encode($pilot) ?> 

 

if it is giving a result then probably you can use the object it is returning

 

Posted (edited)
26 minutes ago, PikoSim said:

Could be your id code id wrong. Can you check what result it is giving by using this

 

<?php echo json_encode($pilot) ?> 

 

if it is giving a result then probably you can use the object it is returning

 

Am I going to add that in the pilot_public_profile.php file?

Edited by Daniboi
Posted

This is the code in PIREPData.class.php:

 

  public static function getLastReports($pilotid, $count = 1, $status = '') {

        if($pilotid == '') {
            return false;
        }

        $sql = 'SELECT * FROM ' . TABLE_PREFIX . 'pireps
					WHERE pilotid=' . intval($pilotid);

        # Check it via the status
        if ($status != '') {
            $sql .= ' AND accepted=' . intval($status);
        }

        $sql .= ' ORDER BY submitdate DESC
					LIMIT ' . intval($count);

        if ($count == 1) return DB::get_row($sql);
        else  return DB::get_results($sql);
    }

 

Posted

And this is the code I use to try to display the reports, but it only gives an empty Array:

<?php echo PIREPData::getLastReports($pilot->pilotid, 5, PIREP_ACCEPTED);
    ?>

 

Posted

Understood what you are trying to do. Basically, getlatreports with 5 counts will return 5 row. Hence, you need to foreach loop. So here is the code i have provided for you. Once you get the idea of it, you can integrate it with your table or display it hwoever you like.
Code

 

 <?php 
   //echo json_encode(PIREPData::getLastReports($pilot->pilotid, 1, PIREP_ACCEPTED)); // This is to get the parameters of the results like pirepid, flighttime etc. Mark out to not use it.
                            
	 $getpireps = PIREPData::getLastReports($pilot->pilotid, 5, PIREP_ACCEPTED); // $getpireps will contain the counted pireps
     foreach($getpireps as $pirep)
     {
   		echo $pirep->pirepid; // Display results based on attribute. 
       echo $pirep->flighttime;
       echo $pirep->depicao;
       // and it goes on 
     }
                    
                    
 ?>

LEt me know if this works for you.

  • Administrators
Posted

Go to your site and after /index.php add /profile/view/<insert_pilot_number_here> and let us know what you see.

So /index.php/profile/view/0002 ---- or any other valid pilot number.

Posted (edited)

Thank you @PikoSim!

this is what I did with what you helped me with, I am into php, but the phpvms is diffrent from what I am used to.

 

Picture

 

And @ProAvia, it wasn’t pilot Information site I would like to reach, I have already it and I just wanted to show the latest flights from that pilot.

Edited by Daniboi
  • Administrators
Posted

Isn't the information at the bottom of that similar to the info you are looking for? The bottom section lists PIREP info for the specific pilot listed. While it shows every PIREP from that specific pilot, the code can probably be edited to only show the last 5 PIREPS.

 

Or are you only wanting to show the last 5 PIREPS - regardless of who submitted them?

Posted
14 hours ago, PikoSim said:

So the code i gave is it correct or its not what you wanted?

It’s perfect, as what you saw if you clicked on the Picture link, you can see what I did with your help, Thank you!

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