Mastering PHP: Making tag clouds

Months ago, I was impressed by the tag clouds featured by many web sites including blogs. I wondered whether I could have that ‘plugin’ in my blog as well.

Today, I realized that it is easy to create a tag cloud function with PHP and PostgreSQL. Currently, I have the following table:

entry_type count percent
accomplishment 11 17
blog 6 9
concepts 1 2
conversation 4 6
diary 17 26
dreams 2 3
father 3 5
husband 1 2
manager 5 8
manager-nct 4 6
networker 1 2
notes 5 8
programming-PHP 6 9

Then, I created a PHP function based on this table so that tags (journal entry types) are displayed with fonts bigger or smaller depending on the number of entries each got as expressed in percentage. I used the scale of 10 to evaluate each of the tag’s percentage. The tag that got 80 percent up receives a font size of 10points. The tag that got 60 to 79 percent receives font size of 9 points, and so on.

My tag cloud

Of course, I can’t apply this learning of mine for my own blog at WordPress.com. I’m not allowed to tinker with the CSS file nor the PHP scripts. It’s all right; what’s more important is that I already know the ropes of tag clouds and I’ve applied them right in my journal system hosted in my own machine.

Powered by ScribeFire.

Advertisements

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