I have this table:
<tbody>
@foreach($datosClase as $datoClase)
@php
$movimiento=($datoClase->total_calmado_movimiento/$datoClase->total_intervalos_movimiento)*100;
$ritmo=($datoClase->total_calmado_ritmo/$datoClase->total_intervalos_ritmo)*100;
@endphp
<tr>
<th>{{$asignaturas[$loop->index]['name']}}</th>
<th>{{$periodos[$loop->index]['time']}}</th>
<th>{{$periodos[$loop->index]['timeFinish']}}</th>
<th>{{$movimiento}}</th>
<th>{{$ritmo}}</th>
<th>
@if ( $movimiento > 90 && $ritmo > 90 )
<img src="{{ asset('img/cinco.png') }}" style="width:30%">
@elseif ( $movimiento > 70 && $ritmo > 70 )
<img src="{{ asset('img/"cuatro.png') }}" style="width:30%">
@elseif ( $movimiento > 60 && $ritmo > 60 )
<img src="{{ asset('img/"tres.png') }}" style="width:30%">
@elseif ( $movimiento > 50 && $ritmo > 50 )
<img src="{{ asset('img/"dos.png') }}" style="width:30%">
@elseif ( $movimiento > 40 && $ritmo > 40 )
<img src="{{ asset('img/"una.png') }}" style="width:30%">
@else
<img src="{{ asset('img/"cero.png') }}" style="width:30%">
@endif
</th>
</tr>
@endforeach
</tbody>
And the problem is that it only shows the iage in the first if.
Here´s the example:
enter image description here
In the second row, as $movimiento is 75 and $ritmo is 100, and both are >70, it should display ‘img/cuatro.png’ but it doesn´t work.
I have tried using a switch instead of if/elseif but it happens still the same.
Any idea?
>Solution :
There are some inconsistencies with your quotes in the src attribute of the img tags.
It should be:
<img src="{{ asset('img/cuatro.png') }}" style="width:30%">
And do the same for the other img tags:
@if ( $movimiento > 90 && $ritmo > 90 )
<img src="{{ asset('img/cinco.png') }}" style="width:30%">
@elseif ( $movimiento > 70 && $ritmo > 70 )
<img src="{{ asset('img/cuatro.png') }}" style="width:30%">
@elseif ( $movimiento > 60 && $ritmo > 60 )
<img src="{{ asset('img/tres.png') }}" style="width:30%">
@elseif ( $movimiento > 50 && $ritmo > 50 )
<img src="{{ asset('img/dos.png') }}" style="width:30%">
@elseif ( $movimiento > 40 && $ritmo > 40 )
<img src="{{ asset('img/una.png') }}" style="width:30%">
@else
<img src="{{ asset('img/cero.png') }}" style="width:30%">
@endif
Once you’ve corrected the quotes, it should properly display the corresponding images for each condition.