PHP Tag Cloud Production--data table structure and query method
For example: If you need an article that contains the tag table with the ID of tagname, which is the tag with the ID of "--", then add the article with the $result =implode (",", $_post[' TagID ');// The array of the captured checkbox is separated by commas $_post[' tagid ') to get an array of foreground check boxes, the foreground HTML part code is: {$tag. tagname}Here is the thinkphp of the writing, the original written in a similar way to store the article, only need to mood table tag= $result can. The data has been saved, and what we need to do next is to click on the corresponding tag to find out all the articles that contain the tag. If we need to display all the tags contained in an article, we need to get the ID of the article, query the tag of the article, use the segmentation function $taglist = explode (', ', $source); The $source is the tag value of the article, for example: Divide tag= "one-way" into an array and then write it in the foreground: for ($index =0; $index Where (' id=%d ', $taglist [$index])->select (); echo "". ($tagsa [0][' tagname ']). " "; The loop output Tagname,url the ID value of the tag table, and the next step is to write a fuzzy query of SQL, the tag like%id% of the article table, where the URL value is received. Note: The above query statements are thinkphp syntax. There is a problem with the fuzzy query, because for example: one of the tag fields in the article table may contain 1, 5 another tag field may contain 10, 23 if the query tag like%1%, you will find the tag fields 1,5 and tag is 10,23 two articles. Even if the like condition is%1,% or%,1,%, it is not possible. So here I write PHP code in the foreground, with two nested for loop to solve, as follows: Copy code $map[' tag ' = Array (' Like ', '% '. TagID. ' %'); Dump ($selecttag [$i] [' ID ']) $arr _mood= $mood->where ($map)->select (); for ($a =0; $a
http://www.bkjia.com/phpjc/871180.html www.bkjia.com True http://www.bkjia.com/phpjc/871180.html techarticle php label Cloud production-- data table structure and query methods for example: If you need an article that contains the tag table with the ID of tagname, which is the tag with the ID of "+", then add the article ...