所以我尝试将时间字符串转换为“X秒前”,并坚持这个问题:
while($row = mysql_fetch_array($result))
<a href="#Profile"><class="profilep" id="postp" /></a>
<ul>
<li class="userName"></li>
<li class="distance"></li>
</ul>
<div class="time">
'.
$eventTime = $row['time'];
$age = time() - strtotime($eventTime);
echo $age "ago"
.'
</div></div>
<p align="justify"></p>
</div>
</article>';
循环不仅加载$ age,还加载$ row ['time']。我想知道它为什么会发生以及如何解决它?感谢您抽出宝贵时间并帮助我学习。
答案 0 :(得分:0)
连接似乎都错了。首先进行计算,然后创建输出。下次请包含正确的代码。
while($row = mysql_fetch_array($result)) {
$eventTime = $row['time'];
$age = time() - strtotime($eventTime);
// Here is probably something missing.
echo '
<a href="#Profile"><[what tag should go here?] class="profilep" id="postp" /></a>
<ul>
<li class="userName"></li>
<li class="distance"></li>
</ul>
<div class="time">' . $age . ' seconds ago</div>
</div>
<p align="justify"></p>
</div>
</article>';
}