Home  >  Article  >  Backend Development  >  有关文章推荐,获取随机文章推荐,帮看看这个代码对不对

有关文章推荐,获取随机文章推荐,帮看看这个代码对不对

WBOY
WBOYOriginal
2016-06-13 12:59:34987browse

相关文章推荐,获取随机文章推荐,帮看看这个代码对不对

$sql = "SELECT * FROM `shops` WHERE `subdomain` != '' ORDER BY RAND() LIMIT 100";<br />
$rows = $db->getData($sql);<br />
foreach($rows as $row)<br />
{<br />
	echo '<li><a href="http://'.$row['subdomain'].'.baidu.com/" title="'.$row['title'].'">'.$row['title'].'</a></li>';<br />
}


在文章页面需要获取随机文章做文章推荐,不知道怎么写,上面的对吗?
------解决方案--------------------
$sql = "SELECT * FROM (SELECT * FROM `shops` WHERE `subdomain` != '' ORDER BY RAND() LIMIT 100) t order by id desc";

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn