Php color Cloud Tag program code

Source: Internet
Author: User
Tags rand regular expression

I found a lot on the internet and found that my system is built on wordpress, so it is not suitable. I think it is very simple to think about the principle.

We define 10 css with no such color and then randomly generate different style names by the program. The specific implementation is as follows.

First, we define the css code.

The code is as follows: Copy code

. Tag {margin: 0 0 20px; width: 230px; height: 234px; padding: 10px; line-height: 28px; overflow: hidden ;}
. Tag a {padding: 5px ;}
. Tag1 {font-size: 12px ;}
. Tag2 {font-size: 12px; color: # 16A ;}
. Tag3 {font-size: 12px; color: # F30 ;}
. Tag4 {font-size: 15px ;}
. Tag5 {font-size: 15px; color: #090 ;}
. Tag6 {font-size: 15px; color: #990 ;}
. Tag7 {font-size: 18px ;}
. Tag8 {font-size: 18px; color: # 06F ;}
. Tag9 {font-size: 18px; color: # 09F ;}
. Tag10 {font-size: 20px ;}
. Tag11 {font-size: 20px; color: #6C0}
. Tag12 {font-size: 20px; color: # F96}

Okay, the next step is not the php program.

The code is as follows: Copy code

Function getKeyZt ($ s, $ e)
{
$ SQL = "select title from your data table order by RAND () desc limit $ s, $ e ";
$ Result = mysql_query ($ SQL) or die (mysql_error ());
While ($ rs = mysql_fetch_array ($ result ))
{
// $ C =
$ Class = 'tag'. rand (1, 12 );
Echo '<a href = "/tags. php /'. urlencode ($ rs ['title']). '/"> <span class = "'. $ class. '"> '. $ rs ['title']. '</span> </a> ';
}

}

The generated html code is as follows:

The code is as follows: Copy code

<A href = "http://www.111cn.net/tags.php/%B1%E9%C0%FA%C4%BF%C2%BC/"> <span class = "tag11"> Traverse directories </span> </a> <a href = "http://www.111cn.net/tags.php/php+date/"> <span class = "tag7 "> php date </span> </a> <a href =" http://www.111cn.net/tags.php/mysql%CA%FD%BE%DD%BF%E2%D3%C5%BB%AF/ "> <span class =" tag3 "> mysql database optimization </span> </a> <a href = "http://www.111cn.net/tags.php/%CD%BC%C6%AC%B4%F3%D0%A1/"> <span class = "tag12"> Image size </span> </a> <a href = "http://www.111cn.net/tags.php/%D1%E9%D6%A4%B5%C7%C2%BC/"> <span class = "tag11"> verify logon </span> </a> <a href = "http://www.111cn.net/tags.php/%CE%C4%BC%FE%CF%C2%D4%D8/"> <span class = "tag3"> File Download </span> </a> <a href = "http://www.111cn.net/http://www.111cn.net/tags.php/js+%D5%FD%D4%F2%B1%ED%B4%EF%CA%BD/"> <span class = "tag6"> js regular expression </span> </a> <a href = "http://www.111cn.net/tags.php/php%CA%FD%D7%E9/"> <span class = "tag7"> php array </span> </a> <a href = "http://www.111cn.net/tags.php/php+ajax/"> <span class = "tag4"> php ajax </span> </a>


The specific effect is as follows:

 

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.