require("config.php");require_once 'Tags.php'; $sql = "SELECT tags FROM demo"; //在这里你可以随机或者限制一下取出的个数. $rs = $db->query($sql); while ($tags = $db->fetch_array($rs)) { $arr[] = split("|",iconv("gb2312","utf-8",$tags['tags'])); } $tags = new Tags($arr); $tagsArr = $tags->getTags(); $tagsStr = ''; foreach ($tagsArr as $value){ $tagsStr .= urlencode(''.$value.''); } $tagsStr .= ''; ?> 复制代码 js代码部分: </li> <li> var rnumber = Math.floor(Math.random()*9999999); </li> <li> var cloud = new SWFObject("Tags/tagcloud.swf?r=" rnumber, "tagcloudflash", "250", "250", "9", "#ffffff"); </li> <li> cloud.addParam("wmode", "transparent"); </li> <li> cloud.addParam("allowScriptAccess", "always"); </li> <li> cloud.addVariable("tspeed", "120"); </li> <li> cloud.addVariable("mode", "tags"); </li> <li> cloud.addVariable("tagcloud", '<?=$tagsStr?>'); </li> <li> cloud.write("Tags"); </li> <li> 复制代码