Yii:用于显示数据库中所有信息的代码

时间:2014-03-12 03:28:46

标签: php yii

我对YII框架很新,所以请耐心等待。 =) 这是我的代码。

    public function actionList()
{
$Employee = new employee;

$data = array('employee' => $Employee);
$this->render('Employee_Display', $data);
}



        <tbody>
    <tr>
        <?php foreach($employee as $row): ?>
        <td><?php $row['employee_firstname']; ?></td>
        <?php endforeach; ?>

    </tr>
</tbody>

我想获取员工姓名列表并以表格形式显示。

1 个答案:

答案 0 :(得分:1)

   public function actionList()
    {
      $Employee = employee::model()->findAll();
      $data = array('employee' => $Employee);
      $this->render('Employee_Display', $data);
    }
        <tbody>
    <tr>
        <?php foreach($employee as $row): ?>
        <td><?php $row->employee_firstname; ?></td>
        <?php endforeach; ?>

    </tr>
</tbody>