0

我认为我的查询没有执行。从->select('name')它只是在我的网站上显示为纯文本。

    <tbody>
    @foreach($getdeaths as $getdeath)
    <tr>
        <? DB::table('players')->select('name')->where('id', $getdeath->player_id)->get(); ?>
        <td>{{ $getdeath->player_id }}</td>
        <td>{{ $getdeath->level }}</td>
        <td>{{ date("d F Y (H:i)", strtotime($getdeath->time)) }}</td>
        <td>@if($getdeath->is_player == 1)
            {{ '<a href="characters/'.$getdeath->killed_by.'">'.$getdeath->killed_by.'</a> (PVP)' }}
            @else
            {{ $getdeath->killed_by }}
            @endif</td>
    </tr>
    @endforeach
</tbody>
4

1 回答 1

0

改变

<? DB::table('players')->select('name')->where('id', $getdeath->player_id)->get(); ?>

<?= DB::table('players')->where('id', $getdeath->player_id)->pluck('name'); ?>

<?方法php

<?=方法php echo

您可以保存 var 并像往常一样回显它:

{{ $x=DB::table('players')->where('id', $getdeath->player_id)->pluck('name'); }}
{{ $x }}
于 2013-08-17T11:22:04.673 回答