我正在用laravel开发一个网站。
我正在使用=>
Laravel版本:5.7
Xampp版本:xampp-win32-7.2.8-0-VC15-installer.exe
引导程序版本:4.1.3
jquery版本:3.3.1
PHP版本:7.2.8
刷新网站时,跳过了一些行。有时它可以正常工作,但有时会跳过一些行,并且HTML标记被破坏。
例如:
blade.php:
<div class="col-lg-4 col-sm-6 mt-3">
<table class="table table-bordered table-striped table-hover">
<thead>
<tr>
<th>Title</th>
<th>Time</th>
<th>Count</th>
</tr>
</thead>
<tbody>
@forelse($bestPosts as $bestPost)
<tr>
<td>{{ $bestPost->title }}</td>
<td>{{ date('d.m.Y', strtotime($bestPost->datetime)) }}</td>
<td>{{ $bestPost->hits }}</td>
</tr>
@empty
<tr>
<td colspan="3" class="text-center bg-warning">No post</td>
</tr>
@endforelse
</tbody>
</table>
</div>
<div class="col-lg-4 col-sm-6 mt-3">
<table class="table table-bordered table-striped table-hover">
<thead>
<tr>
<th>Country</th>
<th>Year</th>
<th>Month</th>
<th>Count</th>
</tr>
</thead>
<tbody>
@forelse($newVisitors as $newVisitor)
<tr>
<td>
<img src="/flags/{{ $newVisitor->country_code3 }}.png" alt="{{ $newVisitor->country_code3 }}" class="border mr-1">
{{ $newVisitor->country_code3 }}
</td>
<td>{{ $newVisitor->year }}</td>
<td>{{ $newVisitor->month }}</td>
<td>{{ $newVisitor->count }}</td>
</tr>
@empty
<tr>
<td colspan="4" class="text-center bg-warning">No visitor</td>
</tr>
@endforelse
</tbody>
</table>
</div>
输出HTML:
我该如何解决这个问题
有时跳过刷新红线
答案 0 :(得分:1)
您在行中缺少SELECT *
FROM post
WHERE valid_month = '' OR valid_month REGEXP '[[:<:]]3[[:>:]]';
<
答案 1 :(得分:1)
尝试此代码:
<div class="col-lg-4 col-sm-6 mt-3">
<table class="table table-bordered table-striped table-hover">
<thead>
<tr>
<th>Title</th>
<th>Time</th>
<th>Count</th>
</tr>
</thead>
<tbody>
@if(count($bestPosts)>0)
@foreach($bestPosts as $bestPost)
<tr>
<td>{{ $bestPost->title }}</td>
<td>{{ date('d.m.Y', strtotime($bestPost->datetime)) }}</td>
<td>{{ $bestPost->hits }}</td>
</tr>
@endforeach
@else
<tr>
<td colspan="3" class="text-center bg-warning">No post</td>
</tr>
@endif
</tbody>
</table>
</div>
<div class="col-lg-4 col-sm-6 mt-3">
<table class="table table-bordered table-striped table-hover">
<thead>
<tr>
<th>Country</th>
<th>Year</th>
<th>Month</th>
<th>Count</th>
</tr>
</thead>
<tbody>
@if(count($newVisitors)>0)
@foreach($newVisitors as $newVisitor)
<tr>
<td>
<img src="{{ '/flags/'.$newVisitor->country_code3 }}.png" alt="{{ $newVisitor->country_code3 }}" class="border mr-1" />
{{ $newVisitor->country_code3 }}
</td>
<td>{{ $newVisitor->year }}</td>
<td>{{ $newVisitor->month }}</td>
<td>{{ $newVisitor->count }}</td>
</tr>
@endforeach
@else
<tr>
<td colspan="4" class="text-center bg-warning">No visitor</td>
</tr>
@endif
</tbody>
</table>
</div>