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

48 comments so far

  1. Winslie Gomez on

    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 on

    @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. http://pressposts.com/Education/Tutorial-How-To-make-Tag-Cloud-using-PHP–MySQL/

    Submited post on PressPosts.com – “Tutorial: How-To make a Tag Cloud using PHP & MySQL”

  4. Great Cornholio on

    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!

  5. srinix on

    @Cornholio
    Thanks a lot for sharing with us.

    PEAR is no doubt one of the best libraries.

    Cheerz
    Sridhar

  6. Great Cornholio on

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

  7. nospam2012 on

    is this for the online one or the 2.2 version?

  8. Xjsquvvv on

    Greetings!..
    per3va2cho4k per3va2cho4k

  9. Kuxajkkk on

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

  10. Bizeyala on

    Thank you for your site.
    alaska salmon fishing+ kenai

  11. Taniuala on
  12. Casyeala on
  13. Tizejala on

    interesting thank you…
    wasilla alaska fishing+ lodge

  14. Pawyeala on

    interesting thank you…
    alaska en fishing+ language salmon

  15. Alex on

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

    Thank you.

  16. srinix on

    Alex,

    Yes u can add external URL as well :)

  17. Alex on

    Could you please tell me how ?
    Thank you.

  18. Mjseoxox on

    big free movie pizza sausage
    big free movie pizza sausage

  19. Ed on

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

  20. XqTjOuon on

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

  21. Kunajpop on

    gluten wheat free diet
    gluten wheat free diet

  22. Pqhjiuon on

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

  23. Hapyjxox on

    zone diet food pyramid
    zone diet food pyramid

  24. KOsAeuon on

    buy 30mg phentermine no prescriptions
    buy 30mg phentermine no prescriptions

  25. TemUjuon on

    buy 30mg phentermine no prescriptions
    buy 30mg phentermine no prescriptions

  26. VeCAiuon on

    buy 30mg phentermine no prescriptions
    buy 30mg phentermine no prescriptions

  27. Zopiypop on

    enterprise car renta
    enterprise car renta

  28. RApiUuon on

    womans
    womans

  29. KjxAquon on

    phentermine
    phentermine

  30. SUgeyuon on

    phentermine uk no prescriptions
    phentermine uk no prescriptions

  31. [...] read more | digg story [...]

  32. RObyjggg on

    advantage car rental denver airport
    advantage car rental denver airport

  33. TAXUiggg on

    aw
    aw

  34. Whardarne on

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

  35. XqmOyuon on

    Na2011b11backs
    m

  36. LAKeiuon on

    Na2011b11backs
    s

  37. CUDjekok on

    fghjnffssefxc
    holiday

  38. matt on

    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

  39. CObiAuon on

    g
    g

  40. SEO Report on

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

  41. Jacka on

    I get non stop errors

  42. Pat on

    Here is a nice script for a design tag cloud :

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

    Enjoy

  43. WqKAOuon on

    hot
    hot

  44. NACequon on

    best
    best

  45. Edelhure Düsseldorf on

    Nice article… funny thing, these tag-clouds.

    Gonna check it out right away!

  46. João F. Melo on

    Very good this script ;)
    Multi Art’s Informatica

  47. edelhure in düsseldorf on

    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?

  48. WebTim.biz on

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

    Thank you for help …


Leave a reply