php - laravel 4.1 用数据库中的数据填充表格

标签 php mysql json laravel

我正在尝试用我的数据库中的数据填充表我用 laravel 4.2 完成了但在 4.1 中它不起作用 错误是

Undefined variable: questions (View: C:\wamp\www\happy_Road\app\views\home\home.blade.php)

这是风景

<div class="col-md-12">
    <table class="table table-striped table-bordered">
        <thead>
            <tr>
            <th>Thémathique</th>
            <th>Question</th>
            <th>Actions</th>
            </tr>
        </thead>
        <tbody>
        @foreach ($questions as $question)
        <tr>
        <td>{{ $question->theme }}</td>
        <td>{{ $question->question }}</td>

        <td >
        </td>

        </tr>
        @endforeach
        </tbody>
        <tfoot></tfoot>
        </table>
        {{  $questions->links(); }}
</div>  

这是 Controller

public function index()
{
        if (Auth::check())
        {
            $questions = questionList::paginate(10);
            return View::make('home.home')->with('user',Auth::user());
        }
        else
        {
            return Redirect::to('login')->with('message',"Vous devez vous connecter d'abord");
        }

}

这个方法有什么问题!!请帮忙!谢谢 :)

最佳答案

将问题传递给您的 View

return View::make('home.home')
    ->with('questions', $questions)
    ->with('user', Auth::user());

关于php - laravel 4.1 用数据库中的数据填充表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25566787/

相关文章:

php - 如何对flv视频进行悬停预览?

php - 尝试访问从 JSON 数据创建的数组时未定义

php - 从 Laravel 输出原始 HTML

c# - 通过 DataGrid 在 DataTable 中插入新行时更新主键

php - 如何在内联 block 中输出 mysqli 查询行?

android - 如何访问从 JSON 对象返回的值

json - URLSession 错误

php - 编写这两个 SQL 查询的更好方法?

java - MySQL 查询获取球体中的行(X、Y、Z 坐标)?

arrays - 如何解析字段名称中具有随机哈希值的golang json数组