[英]PHP MySQL add a empty raw between weeks on a table
Hi i have a list of dates which fetched from mysql.嗨,我有一个从 mysql 获取的日期列表。 and shows on a table like this
并显示在这样的桌子上
04-03-2013
05-03-2013
16-03-2013
18-03-2013
20-03-2013
01-04-2013
04-04-2013
05-04-2013
06-04-2013
i need to show a empty row between weeks on my table我需要在我的桌子上的几周之间显示一个空行
ex前任
04-03-2013
05-03-2013
---------------
16-03-2013
18-03-2013
20-03-2013
---------------
01-04-2013
04-04-2013
---------------
05-04-2013
06-04-2013
---------------
i tried some codes with PHP but no luck, any one know how to do this kind of thing.我用 PHP 尝试了一些代码但没有运气,任何人都知道如何做这种事情。 thank you
谢谢
打印时计算该特定日期的周并将其存储在数组中。对于下一行,使用in_arry()
将数组中的值与计算出的周进行比较,如果它存在,则仅打印该值,如果其中没有值数组将值推入数组,然后打印行并打印值。
$fetched = array("04-03-2013", "05-03-2013", "16-03-2013",);
$i=0;
while (true) {
if ($i>count($fetched)-1) { break; }
$ThisDate = $fetched[$i]; $i++;
$DateObj = new Datetime($thisDate);
$thisWeek = $DateObj->format("W");
if (isset($lastWeek) && $lastWeek!=$thisWeek) { echo "----- -----<br />"; }
echo $ThisDate . "<br />";
$lastWeek = $thisWeek;
}
or .... 要么 ....
$fetched = array("04-03-2013", "05-03-2013", "16-03-2013",);
foreach ($fetched as $f) {
$DateObj = new Datetime($f);
$thisWeek = $DateObj->format("W");
if (isset($lastWeek) && $lastWeek!=$thisWeek) { echo "-----<br />"; }
echo $ThisDate . "<br />";
$lastWeek = $thisWeek;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.