Daniboi Posted June 15, 2020 Report Share Posted June 15, 2020 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. Quote Link to comment Share on other sites More sharing options...
PikoSim Posted June 16, 2020 Report Share Posted June 16, 2020 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 Quote Link to comment Share on other sites More sharing options...
Daniboi Posted June 16, 2020 Author Report Share Posted June 16, 2020 (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 June 16, 2020 by Daniboi Quote Link to comment Share on other sites More sharing options...
Daniboi Posted June 16, 2020 Author Report Share Posted June 16, 2020 That code made it show everything for the pilot, but not the thing I wanted? Quote Link to comment Share on other sites More sharing options...
PikoSim Posted June 16, 2020 Report Share Posted June 16, 2020 Yea so it is showing something. So when it is printing out, is it id or pilotid? Quote Link to comment Share on other sites More sharing options...
Daniboi Posted June 16, 2020 Author Report Share Posted June 16, 2020 It shows all stuff for the pilot in the database, but it still have a empty Array. Quote Link to comment Share on other sites More sharing options...
Daniboi Posted June 16, 2020 Author Report Share Posted June 16, 2020 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); } Quote Link to comment Share on other sites More sharing options...
Daniboi Posted June 16, 2020 Author Report Share Posted June 16, 2020 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); ?> Quote Link to comment Share on other sites More sharing options...
PikoSim Posted June 16, 2020 Report Share Posted June 16, 2020 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. Quote Link to comment Share on other sites More sharing options...
Administrators ProAvia Posted June 16, 2020 Administrators Report Share Posted June 16, 2020 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. Quote Link to comment Share on other sites More sharing options...
Daniboi Posted June 16, 2020 Author Report Share Posted June 16, 2020 (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 June 16, 2020 by Daniboi Quote Link to comment Share on other sites More sharing options...
Administrators ProAvia Posted June 17, 2020 Administrators Report Share Posted June 17, 2020 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? Quote Link to comment Share on other sites More sharing options...
PikoSim Posted June 17, 2020 Report Share Posted June 17, 2020 So the code i gave is it correct or its not what you wanted? Quote Link to comment Share on other sites More sharing options...
Daniboi Posted June 17, 2020 Author Report Share Posted June 17, 2020 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! Quote Link to comment Share on other sites More sharing options...
PikoSim Posted June 17, 2020 Report Share Posted June 17, 2020 Alright. Glad i managed to help you 1 Quote Link to comment Share on other sites More sharing options...
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.