我正在尝试从MySQL数据库,其构造为跟着过去看页面观看项:获得最后从MySQL时间戳
articles table
id | title | content | created
----------------------------------------
1 | title-1 | info-1 | 1386478352
2 | title-2 | info-2 | 1386532855
3 | title-3 | info-3 | 1386637325
4 | title-4 | info-4 | 1386812249
5 | title-5 | info-5 | 1387094028
我想获得最后的浏览页面,不知道多少时间会是足够的,因为每次网站页面刷新此功能将被称为..但是,这是我已经尝试过,但它不会返回任何东西。
"SELECT * FROM articles WHERE TIMESTAMPDIFF(MINUTE, created,NOW()) < 10 LIMIT 2"
但正如我所说的,它不返回单个数据。这就是我试图打印信息的方式。
$loopOne = 0;
foreach($articleLastView as $recent)
{
$recent_id = $recent['id'];
$recent_title = $recent['title'];
$recent_created = $recent['created'];
if ($loopOne == 0)
{
echo 'I print info here if result is the first';
$loopOne++;
}
else if($loopOne == 1)
{
echo 'I print info here if result is the second';
$loopOne++;
}
}
也许我失去了一些东西,但列'created'是如何与最后一次观看的时间?我会想象该字段将包含文章创建时间的时间戳... – jeroen
您提供的数据的期望结果是什么? –