Reputation: 429
I have dynamic data where it could always change. For example:
This is what I have now:
Sometimes like this:
|==============|======|====|====|
|List of people|John |June|Tom |
|Date Join |2017 |2018|2016|
|Hobby |soccer| |
|Remark | test test |
And sometime I would get like this:
|==============|======|======|=====|
|List of people|John |June |Tom |
|Date Join |2017 |2018 |2016 |
|Hobby |soccer|tennis| |
|Remark | test test |
I want to make something like this: (is there any way to do it?)
|==============|======|====|====|
|List of people|John |June|Tom |
|Date Join |2017 |2018|2016|
|Hobby | soccer |
|Remark | test test |
or like this:
|==============|======|====|====|
|List of people|John |June|Tom |
|Date Join |2017 |2018|2016|
|Hobby | soccer|Tennis |
|Remark | test test |
Here is the code I used: (this is how I do it for list of people, date and hobby)
@foreach($object7 as $val)
<tr>
<th style="border: 1px black solid">List of people</th>
<?php
$test = $val->people;
$testa = rtrim($test, ', ');
$array = explode(', ', $testa);
$count4 = count($array);
?>
@foreach($array as $item)
@if(($val->people == NULL) || ( $count4 <= 1))
<td style="border: 1px black solid" colspan="8">
@else
<td style="border: 1px black solid" colspan="1">
@endif
{{$item}}
</td>
@endforeach
</tr>
@endforeach
EDIT: The remark row only has 1 value while the rest can have more than 1 value or more. What I want is based on all this, how can I make all of them the same length?
Upvotes: 1
Views: 84
Reputation: 166
Try the "colgroup" tag lets try to set their width to make it fix:
@foreach($object7 as $val)
<tr>
<td style="border: 1px black solid" with="40%">List of people</td>
<?php
$test = $val->people;
$testa = rtrim($test, ', ');
$array = explode(', ', $testa);
$count4 = count($array);
?>
@foreach($array as $item)
@if(($val->people == NULL) || ( $count4 <= 1))
<td style="border: 1px black solid" with="60%">
@else if($count4 == 2)
<td style="border: 1px black solid" with="40%">
@else
<td style="border: 1px black solid" with="20%">
@endif
{{$item}}
</td>
@endforeach
</tr>
Upvotes: 1