最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

php標(biāo)簽云的實(shí)現(xiàn)代碼

 更新時(shí)間:2012年10月10日 21:20:54   作者:  
下面的實(shí)現(xiàn)代碼,將標(biāo)簽從數(shù)據(jù)庫中搜出來,并格式化處理,使其以出現(xiàn)的次數(shù)為依據(jù)顯示出不同大小的文字連接
數(shù)據(jù)庫中,存放文章的表中有“Tag”字段,用來存放標(biāo)簽。標(biāo)簽之間用“,”分隔。比如“PHP,VB,隨筆”。
下面的實(shí)現(xiàn)代碼,將標(biāo)簽從數(shù)據(jù)庫中搜出來,并格式化處理,使其以出現(xiàn)的次數(shù)為依據(jù)顯示出不同大小的文字連接。
其中的細(xì)節(jié),不做解釋了!
觀念陳、方法笨、效率低的標(biāo)簽云的實(shí)現(xiàn)代碼如下:
復(fù)制代碼 代碼如下:

/**
* WNiaoBlog Tag Template ShowTag
*
* @package WNiaoBlog
*
* @subpackage Tag
*/
//Connect the database
//include('../include/config.php');
/**
* CountTag() - Statistics labels appear the number,and the data to be stored in the two array
*
* GetTag() - Access the Tag's Labels from the database
*/
function CountTag($String){
$TagString = $String;
//echo $TagString."
";
$Tags = explode(",",$TagString);
$n = 1;
$i = 0;
$Continue = TRUE;
//echo $Tags[1]."
";
//in case no-label's article
while($Tags[$n] OR $Tags[++$n] OR $Tags[++$n] ){
$EachTag = $Tags[$n++];
//echo $EachTag."
";
$Continue = TRUE;
for($i=0;$Continue;$i++){
if( $EachTagStr[$i][0] ) {
if( $EachTagStr[$i][0] == $EachTag ){
$EachTagStr[$i][1]++;
$Continue = FALSE;
}
else {
if( $EachTagStr[$i+1][0] ) $Continue = TRUE;
else {
$EachTagStr[$i+1][0] = $EachTag;
$EachTagStr[$i+1][1] = 1;
$Continue = FALSE;
}
}
} else { //initialize the array $EachTagStr[][]
$EachTagStr[$i][0] = $EachTag;
$EachTagStr[$i][1] = 1;
$Continue = FALSE;
}
}
}
return $EachTagStr;
}
function ShowTag($Row,$ablink){
$i = 0;
while($Row[$i][0]){
$EachTag = $Row[$i][0];
$EachCount = $Row[$i][1];
$Size = SetSize($EachCount);
echo " < a style='color:BLUE ; font-size:".$Size." ' onMouseOver=this.style.color='#900000' onMouseOut=this.style.color='BLUE' href='".$ablink."tag?tag=".$EachTag."' target='_self' > ".$EachTag."(".$EachCount.")"." ";
$i++;
}
}
function GetTag(){
$QuerySet = mysql_query("select * from article");
while($Row = mysql_fetch_array($QuerySet)){
$Tag = $Row['tag'];
$TagString = $TagString.",".$Tag;
}
return $TagString;
}
function SetSize($Size){
$Size += 10;
if($Size > 30)
$Size = 30;
return $Size;
}
//Go
echo "
";
echo "標(biāo)簽云";
$String = GetTag();
$Row = CountTag($String);
ShowTag($Row,$ablink);
echo "
";
?>

OK,DONE!

相關(guān)文章

最新評(píng)論

柞水县| 皮山县| 定日县| 淮滨县| 乐业县| 蓬莱市| 内江市| 松滋市| 曲松县| 大渡口区| 呼图壁县| 襄城县| 平谷区| 广平县| 佛冈县| 花莲县| 泽州县| 荆州市| 锦屏县| 通许县| 武隆县| 巴马| 平利县| 阳新县| 余庆县| 五台县| 呼和浩特市| 醴陵市| 泉州市| 会昌县| 滦南县| 当雄县| 新营市| 封开县| 屏南县| 盱眙县| 林芝县| 宁安市| 鲁甸县| 青田县| 麻阳|