[英]date range wise fetch data
I have two date filter 1.from 2.to .if i select date from to To then it show all the data related to current month .我有两个日期过滤器 1.from 2.to .if 我选择日期 from to To 那么它显示与当前月份相关的所有数据。 I have create two variable
我创建了两个变量
how to run a for loop in each field from start_date to end date?如何在从开始日期到结束日期的每个字段中运行 for 循环? i also attached my table picture
我还附上了我的桌子图片
I just want to fetch selected date data.我只想获取选定的日期数据。 Table header is done it show current selected date.
表头完成它显示当前选择的日期。 [1]: https://i.stack.imgur.com/kbzZs.png
[1]: https : //i.stack.imgur.com/kbzZs.png
here is my code这是我的代码
$start_date=date('d',strtotime($from)); $start_date=date('d',strtotime($from)); $end_date=date('d',strtotime($to));
$end_date=date('d',strtotime($to));
<th>Type</th>
<?php
$dates = range($end_date, $start_date);
foreach ($dates as $fpi) {
echo '<th>' . $fpi . '</th>';
}
?>
</tr>
</thead>
<tbody class="text-center">
<tr>
<td class="font-weight-bold text-no-wrapping">man</td>
<?php
foreach ($data['man'] as $value) {
echo '<td>' . number_format($value) . '</td>';
}
?>
</tr>
<tr>
<td class="font-weight-bold text-no-wrapping">women</td>
<?php
foreach ($data['women'] as $value) {
echo '<td>' . number_format($value) . '</td>';
}
?>
</tr>
<tr>
<td class="font-weight-bold text-no-wrapping">children</td>
<?php
foreach ($data['children'] as $value) {
echo '<td>' . number_format($value) . '</td>';
}
?>
</tr>
<tr>
<td class="font-weight-bold text-no-wrapping">as</td>
<?php
foreach ($data['as'] as $value) {
echo '<td>' . number_format($value) . '</td>';
}
?>
</tr>
<tr>
<td class="font-weight-bold text-no-wrapping">ot define</td>
<?php
foreach ($data['not_define'] as $value) {
echo '<td>' . number_format($value) . '</td>';
}
?>
</tr>
<tr>
<td class="font-weight-bold text-no-wrapping">old</td>
<?php
foreach ($data['old'] as $value) {
echo '<td>' . number_format($value) . '</td>';
}
?>
</tr>
</tbody>
</table>
</div>
</div>
this will loop through the dates range, feel free to change $date->format('Ymd)
to what you need这将遍历日期范围,随意将
$date->format('Ymd)
更改$date->format('Ymd)
您需要的
$date = $start_date
while($date <= $end_date){
echo '<th>' . $date->format("Y-m-d"). '</th>';
$date->modify('+1 day');
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.