点击页码时分页不起作用

问题描述:

我正在使用laravel分页。当我点击下一页或任何页码时,没有任何反应。 控制器功能点击页码时分页不起作用

public function getIndex() 
{ 
    $articles = Inspector::paginate(15); 
    return view('admin.inspector.test', compact('articles')); 
} 

查看文件

 <table class="table table-bordered" id="mytable"> 
         <thead> 
          <tr> 
           <th>Sr. No.&nbsp;</th> 
           <th>Email</th> 
          </tr> 
         </thead> 
         <tbody> 
          @foreach ($articles as $article) 
          <tr> 
          <td>{{ $article->id }}</td> 
          <td>{{ $article->email }}</td> 
          </tr> 
          @endforeach 
         </tbody> 
        </table> 
        {!! $articles->render() !!} 

任何帮助深表感谢......感谢......

+0

什么是错误?你是否尝试过使用'{!! str_replace('/?','?',$ articles-> render())!!} –

public function getIndex() 
{ 
    return view('admin.inspector.test'); 
} 

只返回视图,同时调用动作。不要从控制器发送任何数据,只需在视图加载时加载视图 ,使用分页方法获取数据库连接。并将分页显示如下

<?php $articles = DB::connection('table_name')->where('if any condition')->get(); ?> 
    <table class="table table-bordered" id="mytable"> 
          <thead> 
           <tr> 
            <th>Sr. No.&nbsp;</th> 
            <th>Email</th> 
           </tr> 
          </thead> 
          <tbody> 
           @foreach ($articles as $article) 
           <tr> 
           <td>{{ $article->id }}</td> 
           <td>{{ $article->email }}</td> 
           </tr> 
           @endforeach 
          </tbody> 
         </table> 
         {!! $articles->render() !!} 
+0

可以请您详细说明一下...如果我没有返回数据与视图,它应该如何获取数据从db ...! – Aamir

+1

为你的答案投票 – mydo47

+0

你可以做的只是在视图本身上运行数据库连接...试试看... –