resolate Posted June 5, 2017 Share Posted June 5, 2017 Hello, I have some trouble in my code. For now i am trying to output an amortization table that i calculated inside a class. I achieve for the table to be outputted, but there is also an instance of ">>>>>" being outputted and i do not know from where... I have added an image below so you can see the output of the ">>>>". Here's my code: <?php include './index.php'; $val = new Validator(); $input = new Input($val->getSanitized()['input-aw'], $val->getSanitized()['input-i'], $val->getSanitized()['input-n']); $loanHL = new LoanHL($input); $loanHL->calculate(); ?> <table class="table"> <thead> <tr> <th>periode</th> <th>schuld</th> <th>aflossing</th> <th>waarvan intrest</th> <th>waarvan kapitaal</th> <th>restschuld</th> </tr> </thead> <tbody> <?php foreach ($loanHL->getCalculateData() as $key => $val) { echo '<tr>'; echo '<td>' . $loanHL->getCalculateData()[$key]['period'] . '</td>>'; echo '<td>' . $loanHL->getCalculateData()[$key]['aw'] . '</td>>'; echo '<td>' . $loanHL->getCalculateData()[$key]['payment'] . '</td>>'; echo '<td>' . $loanHL->getCalculateData()[$key]['intrestPayment'] . '</td>>'; echo '<td>' . $loanHL->getCalculateData()[$key]['capitalPayment'] . '</td>>'; echo '<td>' . $loanHL->getCalculateData()[$key]['debt'] . '</td>>'; echo '</tr>'; } ?> </tbody> </table> The calculatedata comes from the following two things: public function getCalculateData() { return $this->calculateData; } public function calculate() { $annuity = $this->calcAnnuity($this->workData['aw'],$this->workData['i'],$this->workData['n']); for ($ii = 0; $ii < $this->workData['n']; $ii++) { $this->calculateData[$ii +1]['period'] = $ii + 1; $this->calculateData[$ii +1]['aw'] = $this->calcAw($annuity,$this->workData['i'],$ii,$this->workData['n']); $this->calculateData[$ii +1]['payment'] = $annuity; $this->calculateData[$ii +1]['intrestPayment'] = $this->calcAw($annuity,$this->workData['i'],$ii,$this->workData['n']) * $this->workData['i']; $this->calculateData[$ii +1]['capitalPayment'] = $annuity - ($this->calcAw($annuity,$this->workData['i'],$ii,$this->workData['n']) * $this->workData['i']); $this->calculateData[$ii +1]['debt'] = $this->calcAw($annuity,$this->workData['i'],$ii + 1,$this->workData['n']); } } Appreciate all the help! Also some pointers on my design pattern are welcome, i am new to PHP OOP trying to get the hang of it grtz, Resolate Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted June 5, 2017 Share Posted June 5, 2017 (edited) Look at your HTML, especially the closing td tags. This is a good opportunity to validate your markup. Edited June 5, 2017 by Jacques1 Quote Link to comment Share on other sites More sharing options...
resolate Posted June 5, 2017 Author Share Posted June 5, 2017 OMG i see it now... Thanks Jackques1. Still it strikes me as a surprise that this code is printed above the table headings, since the ">" duplication is found beneath... Any ideas on my design pattern? I especially have trouble creating my Validator class. There are many to be found as open source libraries, but the configuration makes my head explode with the knowledge i only have at this point... And thanks for the link of the validater, i ll definately be using it Quote Link to comment Share on other sites More sharing options...
Psycho Posted June 5, 2017 Share Posted June 5, 2017 Still it strikes me as a surprise that this code is printed above the table headings, since the ">" duplication is found beneath... Because it is invalid HTML, there is no specification on how it should be displayed. You will likely get different results in different browsers. In this case you have content (the > character) that is between the table tags, but is not within any valid table elements (e.g. TD or TH). Since they aren't "in" the table the browser processor needs to decide what to do with them. Putting them before or after the table makes the most sense. 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.