$tagsa=$tagdata->where('id=%d',$taglist[$index])->select();
}
Loop to output the tagname, and the url passes the id value of the tag table. Next, you only need to write a fuzzy query sql where the url value is received, and the tag of the article table is like %id%.
Note: The above query statements are all thinkphp syntax.
There will be a problem when using fuzzy query like this, because for example: one of the tag fields in the article table may contain 1,5 and the other tag field may contain 10,23
If you query tag like %1%, you will find two articles with tag field 1,5 and tag field 10,23. Even if the like condition is %1,% or %,1,%, it will not work.
So my way of writing here is to write php code in the foreground and use two nested for loops to solve the problem, as follows:
Copy code
$map['tag'] = array('like','%'.tagid.'%');
//dump($selecttag[$i]['id']);$arr_mood=$mood->where($map)->select();for($a=0;$a< count($arr_mood);$a++){
$source=$arr_mood[$a]['tag'];
$taglist = explode(',',$source);
for($index=0;$index
if (tagid == $ taglist [$ Index]) {// When the tagid that comes over exists in the tag field of the article, the output is output.
dump($arr_mood[$a]['title']);//Here you can use echo to output to the front desk
}
}
}
http://www.bkjia.com/PHPjc/871180.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/871180.htmlTechArticlephp tag cloud production - data table structure and query method. For example: if you need a tag table to be included in an article The tagname with id 1,2,3, that is, the tag with id 1,2,3, then add the text...
Statement: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