亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

用模版標(biāo)簽制作一個(gè)用戶信息列表,分頁顯示

Original 2019-05-20 14:47:11 219
abstract:    public function userinfo()    {       //分頁配置       $config = [    
    public function userinfo()
   {
      //分頁配置
      $config = [
         'type' => 'bootstrap',
         'var_page' => 'page',
         
      ];

      //每頁數(shù)量
      $num = 5;

      //是否是簡(jiǎn)單分頁
      $simple = false;

      //獲取所有分頁數(shù)據(jù):返回值是分頁對(duì)象: think\Paginate
      $paginate = StaffModel::paginate($num, $simple, $config);

      //渲染分頁的HTML,返回分頁變量
      $page = $paginate->render();
//    halt($page);
      //將分頁對(duì)象賦值給模板
      $this->view->assign('staffs', $paginate);

      //將分頁變量賦值給模板
      $this->view->assign('page', $page);

      //渲染模板
      return $this->view->fetch();

      //備注: tp51自帶的分頁功能很不靈活,更多時(shí)候,推薦使用自己寫的分頁類

   }
{load href="/static/index/style/bootstrap/css/bootstrap.css" /}
<div class="container">
   <div class="row">
      <h3 class="text-center">員工信息登記錄</h3>
      <div class="col-md-8 col-md-offset-2">
         <table class="table table-bordered table-hover text-center">
            <tr class="info">
               <td>ID</td>
               <td>姓名</td>
               <td>性別</td>
               <td>年齡</td>
               <td>工資</td>
            </tr>
            {empty name="staffs"}
               <h3 style="color: red;">當(dāng)前沒有符合條件的數(shù)據(jù),請(qǐng)檢查~~</h3>
            {else /}
            {volist name="staffs" id="staff"}
            <tr>
               <td>{$staff.staff_id}</td>
               <td>{$staff.name}</td>
               <td>
               {$staff.sex}
               
               {//性別必須是0或1,才是合法數(shù)據(jù)}
               {in name="staff.sex" value="0,1"}
                  {if $staff.sex == 0}
                     男
                  {else /}
                     女
                  {/if}
               {/in}

               </td>
               <td>{$staff.age}</td>
               <td>{$staff.salary}</td>
            </tr>
            {/volist}
            {/empty}

         </table>
         <div class="text-right">{$page|raw}</div>
      </div>
   </div>
</div>

{load href="/static/index/style/jquery.js" /}
{load href="/static/index/style/bootstrap/js/bootstrap.js" /}


Correcting teacher:天蓬老師Correction time:2019-05-20 16:07:48
Teacher's summary:模板寫得不錯(cuò)呢, 盡可能使用模板的標(biāo)簽來寫的

Release Notes

Popular Entries