I have a foreach loop that has data.
I am using a foreach loop to echo the data out into a table.
@foreach($data as $key)
<tr>
<td>{{$key->option_name}}</td>
</tr>
@endforeach()
This gives me a table with one column and 1 row of data. This table only has one data field and instead of one long list of data, i want it spread over 4 columns.
I would like to have 4 columns so the table looks nice and neat.
Please see attached example image.
2
Answers
This is expected. Your code basically performs the following:
Ideally, what you need is a collection of data with the fields you want to add in your table. For example:
instead of creating a new row and column for each data point, simply don’t create a new row by putting the
tr
outside the loop