Good day. I can not understand how to draw a table. I have a view, a controller, a model and a class that processes some data and draws a table, but how to make the table draw in the controller I don’t understand the model classes
<?php namespace Application\Models; class SiteAdressModel { private $firstAdressPart = "http://www.cbr.ru/scripts/XML_daily.asp?date_req="; private $secondAdressPart; public function __construct($takenDate) { $this->secondAdressPart = $takenDate; } public function getFirstAdressPart() { return $this->firstAdressPart; } public function getSecondAdressPart() { return $this->secondAdressPart; } } controller
<?php namespace Application\Controller; use Zend\Mvc\Controller\AbstractActionController; use Zend\View\Model\ViewModel; use Application\Models\SiteAdressModel; use Application\Models\TableCreater; class IndexController extends AbstractActionController { public function indexAction() { return new ViewModel(); } public function mainAction() { $adressPart = \htmlspecialchars($_POST['date']); $model = new SiteAdressModel($adressPart); $tableCreator = new TableCreater($model->getFirstAdressPart(), $model->getSecondAdressPart()); $tableCreator->createXML(); } twist data handler
<?php namespace Application\Models; class TableCreater{ private $finalAdress; private $date; private $content; private $XML; public function __construct($FirstPart, $SecondPart) { $this->finalAdress = $FirstPart; $this->date = date('d/m/Y', strtotime($SecondPart)); $this->finalAdress .= $this->date; } public function createXML() { $this->content = file_get_contents($this->finalAdress); $this->XML = SimpleXMLElement($this->content); } public function getXML() { return $this->XML; } public function createTable() { echo "<table class='table table-striped' border=1>"; echo "<tr><th>Valute ID</th><th>NumCode</th><th>CharCode</th><th>Nominal</th><th>Name</th><th>Value</th></tr>"; foreach ($this->XML->Valute as $entry) { echo "<tr>"; echo "<td>"; echo (string) $entry->attributes(); echo "</td>"; echo "<td>"; echo $entry->NumCode; echo "</td>"; echo "<td>"; echo $entry->CharCode; echo "</td>"; echo "<td>"; echo $entry->Nominal; echo "</td>"; echo "<td>"; echo $entry->Name; echo "</td>"; echo "<td>"; echo $entry->Value; echo "</td>"; echo "</tr>"; } echo "</table>"; } } and view where roaming is going and where the table should be drawn. It does not allow to insert html-markup, but there is an empty table with a header, but further in the table there should be data, how to transfer them there, I, alas, cannot understand