html - Retrieve every model and return three values -
i looking way retrieve models in database. loop through of models , read out values name
, firstname
, phonenumber
.
so far i've gotten , failed go past it:
$searchmodel = new employeesearch(); $dataprovider = $searchmodel->search(yii::$app->request->queryparams);
i looking implement 3 values in simple html table:
<tr><td>$firstname</td><td>$name</td><td>$phone</td></tr>
the table should part of pdf output, ideally save variable:
$html_table = '<tr><td>$firstname</td><td>$name</td><td>$phone</td></tr>';
i need every model fulfills criteria of status = 'active'
in database.
so far i've been able tables via gridview
, not in html template either.
you don't need data provider achieve this, try :
$models = employee::find()->where(['status'=>'active'])->orderby('name asc')->all(); foreach ($models $model) { echo "<tr><td>{$model->firstname}</td><td>{$model->name}</td><td>{$model->phone}</td></tr>"; }
read more : http://www.yiiframework.com/doc-2.0/guide-db-active-record.html#querying-data
Comments
Post a Comment