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

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

WBOY
Release: 2016-06-13 12:59:34
Original
1021 people have browsed it

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

$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 />
}
Copy after login


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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template