我刚开始接触YII框架,只了解一些基础知识,例如CRUD等。我想使用YII创建HTML表格。以下是我的VIEW代码,我渲染了一个数组$results
,其中包含我想要用HTML表格显示的所有记录。
<?php
/* @var $this RrCimyUefDataController */
/* @var $model RrCimyUefData */
$this->breadcrumbs=array(
'Rr Cimy Uef Datas'=>array('index'),
'Create',
);
?>
<table>
<tr>
<th>Serial Number</th>
<th>Business Name</th>
<th>Facebook</th>
<th>Twitter</th>
</tr>
<?php
for($a=0, $b=1;$a<count($results);$a=$a+3,$b++){
if(($a+1)<count($results) && ($a+2)<count($results)){
echo '<tr><td>'.$b.'</td>';
echo '<td>'.$results[$a].'</td>';
echo '<td>'.$results[$a+1].'</td>';
echo '<td>'.$results[$a+2].'</td></tr>';
}
}
//var_dump($results);
?>
</table>
代码运行良好,但没有使用正确的YII方法。
提前感谢您。