<table id="example" class="table table-bordered" width="100%" cellspacing="0">
<thead style="font-size: 12px">
<tr>
<th class="diagonalFalling" rowspan="2">
<label>Item</label>
<label style="float: right;position: relative;bottom:20px">Date</label>
</th>
<th colspan="31"></th>
</tr>
<tr>
<th>1</th>
.
. // 31 column (days)
<th>31</th>
</tr>
</thead>
<tbody>
@foreach($results as $key => $r)
<tr>
<td style="text-align: left">{{ $r->item_name }}</td>
<?php
$price_n_date = explode(',', $r->price_date);
foreach ($price_n_date as $value) {
list($price,$date) = explode ('/',$value)
// How can i compare with day and display value of the day to the column?
}
?>
</tr>
@endforeach
</tbody>
</table>
这是我预期的样本输出 .
这是示例查询结果
-
我正在尝试显示该项目的不同日期的值 .
-
我使用查询将值和日期连接到与项目ID相关的项目组相同的列 .
-
我有一个表用于显示所有日期和相关列中具有值的项目 .
-
我将所有项目循环到表中,循环时我试图将日期列与日期从数据库中获取并显示值(如果存在) .
每个项目的列concat值和日期将如下所示
Output for $r->price_date : 12.00 / 2013-07-13 14:35,32.00 / 2013-07-16 14:35
//With this output, which mean only column 13 and 16 will display value and other will be null.
我应该如何循环$ result然后爆炸$ result-> price_date . 之后,请检查日期列是否与日期匹配 .
任何解决方案吗?是否有更好的建议或解决方案来显示数据?