Jump to content

tag cloud question


Recommended Posts

I would like to create a tag cloud .. but not from a defined array .... but from a column in a database with many entries within a date range ... it could have 100s of entries


my table has the following columns

date, column1, column2, rating



I basically want to find out which are the most common words in column 1 and column 2


a row with date might look like this


record 1

date:2009-07-16 09:10:33Z

column1:red, blue, green

column2: hot, sunny



record 2

date:2009-07-15 09:00:13Z

column1:red, blue

column2: cold, wet




what is the best approach to doing this?


Here is a tutorial I found on tag clouds .. but it's based off a defined array .. I want to base my off my columns that might have hundred of tags and duplicates .. etc


function createTagCloud($tags)  
    //I pass through an array of tags  
    foreach($tags as $tag)  
        $id = $tag['id']; //the tag id, passed through  
        $name = $tag['tag']; //the tag name, also passed through in the array  
        //using the mysql count command to sum up the tutorials tagged with that id  
        $sql = "SELECT COUNT(*) AS totalnum FROM tutorials WHERE tags LIKE '%".$id."%' AND published = 1";  


Link to comment
Share on other sites

  • 3 weeks later...

I want to count how many times words exist in various entires ... so for example if I had these three entries:


#1 - health, sun, dog, cat

#2 - health, sun, cloud, rain

#3 - health, apple, ice cream, cloud


I would like the the script to return the number of times each word is used

(3) health

(2) sun

(2) cloud

(1) dog

(1) cat

(1) rain


Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.