Tutorial: How-To make a Tag Cloud using PHP & MySQL

How to make Tag Cloud using PHP & MySQL

Tag Clouds are pretty common now-a-days in almost all the web 2.0 company sites. Be it Technorati, Zoom CLouds, WordPress, Blogger etc.

Why Tag Clouds are important?

Pretty much for the same reasoon: Appealing Users.

On seeing all these even I have decided to introduce the Tag Cloud feature in our project.

Now, the very important question: How do we code to create a Tag Cloud using PHP & MySql?

Here I will show you how to code it.

First the logic:

1. Collect all the tags & Count{how-many times it has been tagged} from DB{MySQL}

2. Put them into a array {PHP}

3. Calculate the maximum and minimum count of the tags used

4. Now, loop through each tag and just change the size of the font.

5. Define a simple class say “wrapper” which will contain the tag clouds

6. Call the function to generate the tag cloud.  {Javascript}

Now, since Im falling short of time, so I will cut the crap and you guys take the code directly.

Yes, a word from me, I will surely update it as time permits in full detail.

Cheerz

Srinix

PS: Download the Code here: Tag Cloud Code

If you are reading article, you might also be interested in the PHP and Scriptaculous Book I have authored.

The book gives you insights about effects, drag-n-drop, slideshows, applications, auto-completion, in-place editing and more. Complete code snippets and explanations.

PHP and Script.aculo.us Book

PHP and Script.aculo.us Book

CHECK out and BUY the PHP and Script.aculo.us book at Packt official site
http://www.packtpub.com/php-and-script-aculo-us-web-2-0-application-interface/book

Advertisements

About srinix

I am Sridhar, a matured nut, on this planet with water, air and love ;)

55 responses to “Tutorial: How-To make a Tag Cloud using PHP & MySQL”

  1. Winslie Gomez says :

    Srinix,
    Fascinating stuff!
    Haven’t got a clue what it’s about, but wow. I’m impressed.

    Like the quote of the day; That I can cope with.
    winslie

  2. srinix says :

    @Winslie
    If you can scroll down here in blog, towards right pane you can see the mash-up of all the tags.
    Thats wht is a Tag-Cloud. Its eaiser to naviagte using Tag-Cloud.

    Cheerz
    Sridhar

  3. Great Cornholio says :

    just for info:

    for all you PEAR users out there, there is a PEAR package that can help in creating your tag cloud.

    you can find it here:

    http://pear.php.net/package/HTML_TagCloud

    have fun!

  4. srinix says :

    @Cornholio
    Thanks a lot for sharing with us.

    PEAR is no doubt one of the best libraries.

    Cheerz
    Sridhar

  5. Great Cornholio says :

    @srinix:
    well, yes, it offers a lot of interesting stuff, although many PEAR packages suffer from one great disadvantage: size. extensive use of PEAR can, when not implemented wisely, cause great load times and therefore belittle the advantages of external classes and scripting.

  6. nospam2012 says :

    is this for the online one or the 2.2 version?

  7. Xjsquvvv says :

    Greetings!..
    per3va2cho4k per3va2cho4k

  8. Kuxajkkk says :

    interesting thank you…
    breast augmentation new york city san diego breast augmentation

  9. Alex says :

    Hi,
    Great script!
    I have a question, how can I add an external URL on each tag ?
    Like word-cloud script.

    Thank you.

  10. srinix says :

    Alex,

    Yes u can add external URL as well 🙂

  11. Alex says :

    Could you please tell me how ?
    Thank you.

  12. Ed says :

    Thanks. How do I include a URL to do a custom Google search with the cloud?

  13. XqTjOuon says :

    Where it is possible to buy the ? It is very necessary!
    adult thick cocks http://adinox.funpic.org

  14. Pqhjiuon says :

    It is necessary to search correctly. By the way, who to share the helpful information? Where it is possible to find?
    tramadol

  15. Whardarne says :

    Follow these guidelines and you will build that new home with little, or no, problems. alcoa siding can help…

  16. matt says :

    how i can print many words from full text (db)
    example:
    if i have this text: Enter the key you see above
    and want display it as tag like
    enter,the,key,you,see,above

    how to do it

  17. SEO Report says :

    Thanks, the attached coding was exactly what I was looking for…

  18. Jacka says :

    I get non stop errors

  19. Pat says :

    Here is a nice script for a design tag cloud :

    http://www.ilikeyoutube.com/cloud/

    Enjoy

  20. Edelhure Düsseldorf says :

    Nice article… funny thing, these tag-clouds.

    Gonna check it out right away!

  21. edelhure in düsseldorf says :

    Hmmm… word clouds look nice, but I can not lose the feeling that they use up too much screen space.

    Any ideas how to “compress” it a bit?

  22. WebTim.biz says :

    Hi,
    Can you help me …
    I wish to limit number of tags for displey …How can I do theat …

    Thank you for help …

  23. Charles says :

    Hi Stephen,

    If you don’t mind, a high school biology teacher (me) needs your help for this tag cloud script. The linking part is working just fine. The problem I am having is that the script is not counting the number of tags I have for each row entry. It is saying : returned count of 0. The other problem is the comma separated tags name, name2, etc. for each bookmark’s entry tags are tag clouded as a group instead of separate words.

    I have been searching on the Web for three days and cannot find a solution for these questions.

    Is this script suppose to count the tags and put that information back into the dbase and then output it to the tag cloud? or Is this suppose be happening another way, say like when a person post a new entry with added tags?

    How are you implementing script wise for the tag cloud in the right margin on this page? I can see that you are getting the count numbers.

    Sincerely,
    Charles

  24. Events in sweden says :

    I think I’ll implement this om my site!

  25. Lan Tester · says :

    car rental service prices have risen this year. i am saving to buy my one car ,;”

  26. samanthajain12 says :

    how can i download this code file?

  27. pranitsaindani says :

    your code is blocked!

Trackbacks / Pingbacks

  1. PressPosts / User / Mafin / Submitted - June 5, 2007
  2. Olkenava » How to make a Tag CLoud using PHP & MySQL - November 6, 2007

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: