destoon调用随机数据的方法
为了更方便蜘蛛的抓取,会用到随机展示数据,如果用系统标签对效率影响很大,下面就写了一段效率还算差不多的代码,有兴趣的可以尝试一下。二话不说,直接上代码:
//=================================
//随机获取数据id
//=================================
function get_RandomList($listNum)
{
global $db,$DT_TIME;
$tagsx = array();$tagsid = array();
$get_maxid = $db->query("SELECT itemid FROM destoon_sell_5 where status = 3 and thumb <> ''", 'CACHE');
while ($bookInfo = mysql_fetch_array($get_maxid))
{
array_push($tagsid, $bookInfo['itemid']);
}
$get_max = count($tagsid)-1;
for ($x=1; $x<=$listNum; $x++)
{
$round_id = rand(0,$get_max);
$round_id =$tagsid[$round_id];
$result = $db->get_one("SELECT itemid,title,thumb,linkurl,style,introduce,edittime,username,company,groupid,vip,validated,price,unit FROM `{$db->pre}sell_5` where itemid = ".$round_id."", 'CACHE');
$tagsx[] = $result;
}
return $tagsx;
}
**** Hidden Message *****
页:
[1]