-2

我将此代码放在我的壁纸网站的相关壁纸部分。下面的代码向我显示特定标签的壁纸(例如:抽象,爱..),但它向我显示当前壁纸,我想在相关壁纸部分制作随机壁纸。这个怎么做 ?

我的PHP代码:

<?php
//Related wallpaper
$searchtag = $info['tag'];
$related = mysql_query("SELECT * FROM covers WHERE tag='$searchtag' LIMIT 2 ") or       die(mysql_error());
 while($info = mysql_fetch_array($related))
{ 
echo $info['name'];
Echo '<img src="thumb/'.$info['thumbflname'].'"></br>';
}
?>
4

2 回答 2

0
SELECT * FROM covers WHERE tag='$searchtag' LIMIT 2 

应该

SELECT * FROM covers WHERE tag='$searchtag' ORDER BY RAND() LIMIT 2
于 2013-07-16T12:58:22.950 回答
0

也许你可以尝试这样的事情

mysql_query('SELECT * FROM covers WHERE tag="'.$searchtag.'" LIMIT '.rand(1, 55).', 1')

于 2013-07-16T12:58:30.813 回答