php
  • twitter-bootstrap
  • yii
  • pagination
  • 2014-05-25 49 views 1 likes 
    1

    我不知道如何使用我的代碼進行分頁。我會把每頁三個項目,但我不知道如何去做。如果有人能指導我!Yii和Bootstrap分頁訪問

    <?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>"; 
        } 
        } 
        } 
    } 
    
    +0

    使用cgridview的yiibooster部件。它會自動進行分頁。 – MH2K9

    回答

    0

    我覺得最簡單的解決方案是你的問題是CGridView小部件。它有過濾器,分頁和你的代碼會更乾淨。

    看看here

    編輯:您可以使用自舉類或者你可以使用基於引導

    相關問題