PHP Tag Cloud Production--data table structure and query method _php Tutorial

Source: Internet
Author: User
Tags tagname

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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.