Back to [[step_3_-_create_the_crud_for_the_church_info_database|previous page]]
Lets build a page we can call to see the **Weekly Ministries** table.\\

First lets try a method to load all the table data and send it to a test page as suggested from this [[https://steemit.com/utopian-io/@iqbalhood/creating-web-application-using-yii2-framework-connect-and-displaying-data-from-database|page]]\\

In **SiteController** i.e. edit ''controllers\SiteController.php''\\ 
On top, add
<code php>
use app\models\Ministries;
use app\models\MinistriesSearch;
</code>

we put an action
<code php>
    /*
     * Displays Weekly Ministries page.
     *
     * @return string
     */
    public function actionWeeklyMinistries()
    {

        $searchModel = new MinistriesSearch();
        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
        return $this->render('ministries', [
            'searchModel' => $searchModel,
            'dataProvider' => $dataProvider,
        ]);
    }
</code>

Then create a ''views\site\ministries.php'' file with
<code php>
<?php

/* @var $searchModel app\models\MainSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

/* @var $this yii\web\View */

$this->title = 'WMCK';
?>
<div class="site-index">

    <div class="jumbotron">
        <h1>Weekly Ministries</h1>

    <div class="body-content">
        <table class="table table-responsive">
            <tbody class="text-left">
            <?php
                $dname='';
                foreach ($dataProvider->models as $model){
                    if ($model['day']!=$dname) {
                        $dname = $model['day'];
                        echo '<tr class="bg-success"><td width="66%"><strong>'.$dname.'</strong></td><td width="34%"></td></tr>'.PHP_EOL;
                        echo '<tr><td>'.$model['title'];
                        if ($model['content']!=''){
                            echo '<br />'.$model['content'].'</td>';
                        } else {
                            echo '</td>';
                        }
                    }else{
                        echo '<tr><td>'.$model['title'];
                        if ($model['content']!=''){
                            echo '<br />'.$model['content'].'</td>';
                        } else {
                            echo '</td>';
                        }
                    };
                    if ($model['starttime']==NULL) {
                        echo '<td>&nbsp;</td>'.PHP_EOL;
                    } else {
                        echo '<td>'.date('h:i A',strtotime($model['starttime']));
                        if ($model['endtime']!='') {
                            echo '-'.date('h:i A',strtotime($model['endtime'])).'</td>';
                        } else { echo '</td>'; }
                    }
                    echo '</tr>'.PHP_EOL;
 
                };
            ?>
            </tbody>
        </table>
    </div>
</div>

</code>

Call it as [[http://wmck.local/web/index.php?r=site/weekly-ministries]]\\


Go to the [[step_5_-_change_the_main_index_page|next step]]

Back to [[yii|Yii Main Index]]