Jump to content

Code Spacing


shaun105

Recommended Posts

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>

Link to comment
Share on other sites

  • Moderators

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

Link to comment
Share on other sites

  • Moderators

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

Link to comment
Share on other sites

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>';
?>

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