dimanche 28 juin 2015

Multiple if statements in a foreach loop

I have 3 reviews in my database but somehow it only shows 1 of the 3 star ratings as checked and the other 2 reviews star ratings are empty

@foreach($recensies as $recensie)

                <fieldset class="rating">
                    <input type="radio" disabled  @if($recensie->rating == 5) checked="checked" @endif name="rating" value="5" /><label class = "full" for="star5" title="Awesome - 5 stars"></label>
                    <input type="radio" disabled  @if($recensie->rating == '4 and a half') checked="checked" @endif name="rating" value="4 and a half" /><label class="half" for="star4half" title="Pretty good - 4.5 stars"></label>
                    <input type="radio" disabled  @if($recensie->rating == 4) checked="checked" @endif name="rating" value="4" /><label class = "full" for="star4" title="Pretty good - 4 stars"></label>
                    <input type="radio" disabled  @if($recensie->rating == '3 and a half') checked="checked" @endif name="rating" value="3 and a half" /><label class="half" for="star3half" title="Meh - 3.5 stars"></label>
                    <input type="radio" disabled  @if($recensie->rating == 3) checked="checked" @endif name="rating" value="3" /><label class = "full" for="star3" title="Meh - 3 stars"></label>
                    <input type="radio" disabled  @if($recensie->rating == '2 and a half') checked="checked" @endif name="rating" value="2 and a half" /><label class="half" for="star2half" title="Kinda bad - 2.5 stars"></label>
                    <input type="radio" disabled  @if($recensie->rating == 2) checked="checked" @endif name="rating" value="2" /><label class = "full" for="star2" title="Kinda bad - 2 stars"></label>
                    <input type="radio" disabled  @if($recensie->rating == '1 and a half') checked="checked" @endif name="rating" value="1 and a half" /><label class="half" for="star1half" title="Meh - 1.5 stars"></label>
                    <input type="radio" disabled  @if($recensie->rating == 1) checked="checked" @endif name="rating" value="1" /><label class = "full" for="star1" title="Sucks big time - 1 star"></label>
                    <input type="radio" disabled  @if($recensie->rating == 'half') checked="checked" @endif name="rating" value="half" /><label class="half" for="starhalf" title="Sucks big time - 0.5 stars"></label>
                </fieldset>

@endforeach

Here is a picture to show you what I mean.

enter image description here

Aucun commentaire:

Enregistrer un commentaire