Hello,

I am trying to create a picture gallery with laravel:

This is my blade:

setting.blade.php

                                    @if(isset($themes))
                                    @foreach($themes as $m)

                                    <tr>
                                    <td><img width="100px" height="100px" src="{{url('/')}}/uploads/theme/{{$m->pic_name}}.jpg"/></td>
                                    <td><img width="100px" height="100px" src="{{url('/')}}/uploads/theme/{{$m->pic_name}}.jpg"/></td>
                                    <td><img width="100px" height="100px" src="{{url('/')}}/uploads/theme/{{$m->pic_name}}.jpg"/></td>
                                    </tr>

                                    <tr>
                                    <td><div class="box"><input type="checkbox" name="pic" value=""></div></td>
                                    <td><input type="checkbox" name="pic" value=""></td>
                                    <td><input type="checkbox" name="pic" value=""></td>
                                    </tr>

                                    @endforeach
                                    @endif

The above codes would show me a list of three of the same picture in a row and on the next row it changes the picture and again a list of three same picture. I would like each picture all would be different none are the same. How to create such a thing?

Thanks in advance.

Member Avatar for diafol

Only have new tr tags when $i%3 =0 where I is the counter

Member Avatar for diafol

Sorry, thought of a better way:

@for($i=0;$i<count($theme);$i=$i+3)
<tr>
<td>{{{ $theme[$i] or '' }}}</td>
<td>{{{ $theme[$i] or '' }}}</td>
<td>{{{ $theme[$i] or '' }}}</td>
<tr>
@endfor

Not tested

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.