Yii和Bootstrap分页访问

时间:2014-05-25 13:18:30

标签: php twitter-bootstrap yii pagination

我不知道如何对我的代码进行分页。我会在每页放三个项目,但我不知道该怎么做。如果有人可以指导我!

<?php
$rows = Yii::app()->db->createCommand()
->select('username,hash')
->from('cruge_user')
->queryAll();

  echo "<table class='table table-striped' id='connect_table' border=1 style='width:300px'>
            <tr>
              <td>USUARI</td>
              <td>ESTAT</td> 
            </tr><tr>";
  foreach ($rows as $key => $valor) {
  foreach ($valor as $col => $valors) {
    if($col=='username'){
    $username=$valors;
    if($username!=$user){
    echo "<td><i class='icon-user'>__".$valors."</td>";
    }
    }
    //  $( document ).ready(function() {
    if($col=='hash'){
      if($valors!=""){
      if($username!=$user){
      //echo "<td><button id='connect' value='\"$valors\"' type='button'>PLAY</button></td>";
      echo "<td class='success'><button title='clica per jugar' class='btn' id='connect' onclick='envia_hash(\"$valors\")' type='button'></button></td>";
      echo "</tr>";
      }
    }else {
        echo "<td><img title='desconectat' src='../img/disable.png'></td>";
        echo "</tr>";
    }
    }
  }
}

1 个答案:

答案 0 :(得分:0)

我认为最简单的解决方案是CGridView小部件。它有过滤器,分页,你的代码会更清晰。

看看here

编辑:你可以使用bootstrap类,也可以使用基于bootstrap的yiibooster小部件