I had Users table and group table, when i load a group table, it loads the user which have same group_id as the group table id. it works, but my problem is the foreach was quite a mess. the output looks like this..
however, i want to make the output look like this.
here is my code..
<tbody>
<?php $i = 0; ?>
@foreach ($auser as $res)
<?php $i += 1; ?>
<tr @if($i%2==0) class="bgcolor" @endif>
<td>{{ $res->id }}.</td>
<td id="showdet">{{ $res->nama }}</td>
<td>{{ $res->description }}</td>
<?php $user = DB::table('users')->where('devgroup',$res->id)->get();?>
@foreach($user as $mem)
<td>{{ $mem->name }}</td>
@endforeach
<td>
<a class="default-btn" href="/pms/admin/group/edit/{{ $res->id }}">Edit</a>
<a type="submit" class="default-btn del" data-id="devgroup" href="#"{{ $res->id }}">Delete</a>
</td>
</tr>
@endforeach
</tbody>
what did i do wrong? thank you for your help.
You create new
TD
for each member. The nested foreach has to be:The result will be:
I don't know the template engine you used, add inside a loop condition and don't put
<br>
after the last one member.