<small id='LMFU3'></small><noframes id='LMFU3'>

  • <legend id='LMFU3'><style id='LMFU3'><dir id='LMFU3'><q id='LMFU3'></q></dir></style></legend>

      <i id='LMFU3'><tr id='LMFU3'><dt id='LMFU3'><q id='LMFU3'><span id='LMFU3'><b id='LMFU3'><form id='LMFU3'><ins id='LMFU3'></ins><ul id='LMFU3'></ul><sub id='LMFU3'></sub></form><legend id='LMFU3'></legend><bdo id='LMFU3'><pre id='LMFU3'><center id='LMFU3'></center></pre></bdo></b><th id='LMFU3'></th></span></q></dt></tr></i><div id='LMFU3'><tfoot id='LMFU3'></tfoot><dl id='LMFU3'><fieldset id='LMFU3'></fieldset></dl></div>
        <bdo id='LMFU3'></bdo><ul id='LMFU3'></ul>
      <tfoot id='LMFU3'></tfoot>

      1. Yii2 显示每个循环使用的数据

        Yii2 display data using for each loop(Yii2 显示每个循环使用的数据)

          <i id='bY6G1'><tr id='bY6G1'><dt id='bY6G1'><q id='bY6G1'><span id='bY6G1'><b id='bY6G1'><form id='bY6G1'><ins id='bY6G1'></ins><ul id='bY6G1'></ul><sub id='bY6G1'></sub></form><legend id='bY6G1'></legend><bdo id='bY6G1'><pre id='bY6G1'><center id='bY6G1'></center></pre></bdo></b><th id='bY6G1'></th></span></q></dt></tr></i><div id='bY6G1'><tfoot id='bY6G1'></tfoot><dl id='bY6G1'><fieldset id='bY6G1'></fieldset></dl></div>

                <bdo id='bY6G1'></bdo><ul id='bY6G1'></ul>
              • <legend id='bY6G1'><style id='bY6G1'><dir id='bY6G1'><q id='bY6G1'></q></dir></style></legend>
                  <tbody id='bY6G1'></tbody>

                <small id='bY6G1'></small><noframes id='bY6G1'>

                <tfoot id='bY6G1'></tfoot>

                1. 本文介绍了Yii2 显示每个循环使用的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  使用 yii2 我已经使用 gii 创建了一个模型和 CRUD.

                  Using yii2 I have created a Model and CRUD using gii.

                  我想在我的 VIEW 中使用 foreach 或 while 循环以下列格式显示数据

                  I want to use a foreach or while loop in my VIEW to display the data in the following format

                  对于数据库表中的每一行

                  For each row in database table

                  echo("addMarker($lat_field, $lon_field);
                  ");
                  

                  我有一个使用以下控制器操作呈现的索引页.

                  I have an index page which is rendered using the following controller action.

                      public function actionIndex()
                  {
                      $this->layout = 'directory';
                  
                      $searchModel = new ShopDirectorySearch();
                      $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
                  
                      return $this->render('index', [
                          'searchModel' => $searchModel,
                          'dataProvider' => $dataProvider,
                      ]);
                  }
                  

                  我可以使用以下内容使用 listview 显示数据,该列表视图显示数据库中的所有数据/行,但是它周围有 html 并且显然没有以我希望的格式输出.

                  I can use the following to display the data using listview which displays all the data/rows within database however it has html around it and obviously isn't outputted in the format I wish it to be.

                      <?=  ListView::widget([
                   'dataProvider' => $dataProvider,
                   'itemOptions' => ['class' => 'col-xs-6 col-sm-3'],
                   'itemView' => '_index',
                  ]);?>
                  

                  推荐答案

                  这里不需要使用 ListView,你只需尝试:

                  No need to use ListView here, you should simply try :

                  foreach ($dataProvider->models as $model) {
                      echo "addMarker({$model->lat_field}, {$model->lon_field});";
                  }
                  

                  如果你真的想使用 ListView,你可以简单地编辑 _index 视图文件.

                  If you really want to use ListView, you could simply edit _index view file.

                  这篇关于Yii2 显示每个循环使用的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                2. <i id='eNnWM'><tr id='eNnWM'><dt id='eNnWM'><q id='eNnWM'><span id='eNnWM'><b id='eNnWM'><form id='eNnWM'><ins id='eNnWM'></ins><ul id='eNnWM'></ul><sub id='eNnWM'></sub></form><legend id='eNnWM'></legend><bdo id='eNnWM'><pre id='eNnWM'><center id='eNnWM'></center></pre></bdo></b><th id='eNnWM'></th></span></q></dt></tr></i><div id='eNnWM'><tfoot id='eNnWM'></tfoot><dl id='eNnWM'><fieldset id='eNnWM'></fieldset></dl></div>
                  <legend id='eNnWM'><style id='eNnWM'><dir id='eNnWM'><q id='eNnWM'></q></dir></style></legend>

                    <small id='eNnWM'></small><noframes id='eNnWM'>

                      <tbody id='eNnWM'></tbody>

                          <tfoot id='eNnWM'></tfoot>
                            <bdo id='eNnWM'></bdo><ul id='eNnWM'></ul>