Php 将日期标题从上到下移动
我有同一日期的每组的日期标题。这些日期标题当前显示在同一日期的每组顶部。我希望日期标题改为位于同一日期每组的底部。我试过了,但运气不好。有人能告诉我如何改变这个吗?谢谢 明白我的意思了Php 将日期标题从上到下移动,php,html,Php,Html,我有同一日期的每组的日期标题。这些日期标题当前显示在同一日期的每组顶部。我希望日期标题改为位于同一日期每组的底部。我试过了,但运气不好。有人能告诉我如何改变这个吗?谢谢 明白我的意思了 您可以将其保存到如下变量中,而不是回显日期标题 .... $lastHeading = ''; $currentDate = false; while ($row = $resultSet->fetch_assoc()) { if ($row['Date'] != $currentDate){
您可以将其保存到如下变量中,而不是回显日期标题
....
$lastHeading = '';
$currentDate = false;
while ($row = $resultSet->fetch_assoc())
{
if ($row['Date'] != $currentDate){
echo $lastHeading;
$lastHeading = '<strong>' . $row['Date'] . '</strong>' ;
$currentDate = $row['Date'];
}
....
}
echo $lastHeading;
。。。。
$lastHeading='';
$currentDate=false;
而($row=$resultSet->fetch_assoc())
{
如果($row['Date']!=$currentDate){
echo$lastHeading;
$lastHeading='。$row['Date'].';
$currentDate=$row['Date'];
}
....
}
echo$lastHeading;
您链接到的网站输出的代码与上面显示的代码不同。例如,您的站点本身没有
标记
不过,您应该能够将if($row['Date']!=$currentDate){}
块移动到次要回显的下方,以便在底部显示日期,如下所示:
while ($row = $resultSet->fetch_assoc()) {
echo '<ul><li><A HREF="' . $row["Link"] . '">' . $row["Article"] . $row["Date"] . '</A></li></ul>';
if ($row['Date'] != $currentDate){
echo '<strong>' . $row['Date'] . '</strong>';
$currentDate = $row['Date'];
}
}
while($row=$resultSet->fetch_assoc()){
回音“”;
如果($row['Date']!=$currentDate){
回显“”.$row['Date']”。;
$currentDate=$row['Date'];
}
}
请注意,我还将其格式化以使其更清晰
希望这有帮助!:) 嘿,前两次约会效果很好,但最后一次约会却没在最后?感谢
echo$lastHeading
在本周结束后,非常感谢您的帮助!
while ($row = $resultSet->fetch_assoc()) {
echo '<ul><li><A HREF="' . $row["Link"] . '">' . $row["Article"] . $row["Date"] . '</A></li></ul>';
if ($row['Date'] != $currentDate){
echo '<strong>' . $row['Date'] . '</strong>';
$currentDate = $row['Date'];
}
}