shaun105 Posted July 31, 2015 Report Share Posted July 31, 2015 I have top 5 pilots on home page, however the callsign and total hours show like this ... callsign is EIN1234 and the hours are 67 there isnt a space. Could you tell me how to do this. I have added the code below. Thanks in advance. EN123467 <?php $year = date("Y"); $month = date("m")-1; if($month == 0) { //If it's january, previous month is december. $month = 12; $year -= 1; } $pilot = TopPilotData::top_pilot_hours($month, $year, 5); echo '<table>'; foreach ($pilot as $top) { $pilot = PilotData::GetPilotData($top->pilot_id); echo '<tr>'; echo '<td>'.$pilot->firstname.' '.$pilot->lastname.' - '.PilotData::GetPilotCode($pilot->code, $pilot->pilotid).'</td>'; echo '<td>'.$top->hours.'</td>'; echo '</tr>'; } echo '</table>'; ?> </div> Quote Link to comment Share on other sites More sharing options...
Moderators servetas Posted July 31, 2015 Moderators Report Share Posted July 31, 2015 You set a percentage width for each <td>. For example: <td width="50%"> This will give specific "space" for each table column. Quote Link to comment Share on other sites More sharing options...
shaun105 Posted July 31, 2015 Author Report Share Posted July 31, 2015 Thanks again done the job for me Quote Link to comment Share on other sites More sharing options...
shaun105 Posted August 3, 2015 Author Report Share Posted August 3, 2015 One more ref the code above that is for the previous month pilot hours total. What would be the code for showing the present month please. Quote Link to comment Share on other sites More sharing options...
Moderators servetas Posted August 3, 2015 Moderators Report Share Posted August 3, 2015 Do not expect everything "on your plate". If you check the code it is obvious. On the second line we store the current year on the $year variable. On the third line we store the current month-1(which means the previous month) on the $month variable. As soon as you remove the -1 from the $month, the whole if statement is useless and it can be removed too (lines 4-7). Customize the above code based on what i wrote, and you will have the present month stats ready. Quote Link to comment Share on other sites More sharing options...
shaun105 Posted August 3, 2015 Author Report Share Posted August 3, 2015 Yeah thanks for the pointer and the attitude. Is this a support forum ? Some of us not as clued up with codes ect. Please accept my plate for any further issues. Quote Link to comment Share on other sites More sharing options...
Moderators servetas Posted August 3, 2015 Moderators Report Share Posted August 3, 2015 I know that some of you do not know a lot of things about coding. As you have noticed, i am always trying to help the community members as much as i can, whenever i can and wherever i can. The thing is that we are not here to serve you ready codes to build your website. I did not say it to offend you. I fully explained you how to do it with three fully comprehensible steps. It's not that bad to run it, experiment and make a few tests. It might take you some time but in the end, you will learn much more things than just copying it. Quote Link to comment Share on other sites More sharing options...
shaun105 Posted August 3, 2015 Author Report Share Posted August 3, 2015 I appreciate that and the help. Website is already built i am just tuning it a bit. I am not a webmaster with PHP I will try yo sort myself Quote Link to comment Share on other sites More sharing options...
Moderators servetas Posted August 3, 2015 Moderators Report Share Posted August 3, 2015 This is something quite simple and that is why i just described you how to do it. Read what i said above and i am sure that you will manage to do it. Post the code for us as soon as you complete it. Quote Link to comment Share on other sites More sharing options...
shaun105 Posted August 3, 2015 Author Report Share Posted August 3, 2015 It was staring me in the face thanks <?php $year = date("Y"); $month = date("m"); $pilot = TopPilotData::top_pilot_hours($month, $year, 5); echo '<table>'; foreach ($pilot as $top) { $pilot = PilotData::GetPilotData($top->pilot_id); echo '<tr>'; echo '<td>'.$pilot->firstname.' '.$pilot->lastname.' - '.PilotData::GetPilotCode($pilot->code, $pilot->pilotid).'</td>'; echo '<td width="10%"><td>'.$top->hours.'</td>'; echo '</tr>'; } echo '</table>'; ?> 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.