In my previous question, I got to perform a raw SQL query.
I've declared an public function in my controller:
public function deaths()
{
$getdeaths = DB::statement('SELECT * FROM player_deaths ORDER BY time DESC LIMIT 10');
return View::make('main.latestdeaths')->with('getdeaths', $getdeaths);
}
When retrieving data, I want to display players name, so inside the view in a foreach, is tried to run a SQL query.
@foreach($getdeaths as $getdeath)
<tr>
<? $name = DB::select( DB::raw('SELECT name FROM players WHERE id = '$getdeath->player_id'') ) ?>
<td>{{ $getdeath->player_id }}</td>
<td></td>
<td></td>
</tr>
@endforeach
When I try to echo $name, the variable is not defined.
Can I parse it some other way?