lundi 22 juillet 2019

Table not displaying its contents in displaydata.blade.php

Table not displaying its contents saying undefined variable users

Undefined variable: users (View: C:\xampp\htdocs\Task_List\resources\views\displaydata.blade.php)

    <html>

    <div class="panel-body">
    <fieldset>

    <legend>User Records</legend>
    <table>
    <thead>
        <tr>
            <th>ID</th>
            <th>Name</th>
            <th>Password</th>        
        </tr>
    </thead>
  <tr>
      @foreach($users as  $user)
    <td>     </td>
    <td>     </td>
    <td>     </td>
    </tr>
        @endforeach


<input type="hidden" value= name=_token>
    </table>
    </div>
    </body>
</html>

DisplayController has the following code:

class DisplayDataController extends BaseController
{
    public function displaydata()
    {
        $users = DB::table('users')->select('id','email','password')->get();

        return view('displaydata',['users'=> $users]);
    }
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire