有关文章推荐,获取随机文章推荐,帮看看这个代码对不对
时间:2021-07-01 10:21:17
帮助过:2人阅读
相关文章推荐,获取随机文章推荐,帮看看这个代码对不对
$sql = "SELECT * FROM `shops` WHERE `subdomain` != '' ORDER BY RAND() LIMIT 100";
$rows = $db->getData($sql);
foreach($rows as $row)
{
echo '
'.$row['title'].'';
}
在文章页面需要获取随机文章做文章推荐,不知道怎么写,上面的对吗?
------解决方案--------------------$sql = "SELECT * FROM (SELECT * FROM `shops` WHERE `subdomain` != '' ORDER BY RAND() LIMIT 100) t order by id desc";