Tag cloud with more exacting data?

Its late Im tired and I can’t seem to get started on a simple task.

Want to create a Word cloud but with more exacting data from database.

I update words on the table based on search count.

Term1 = 22 times
Term2 = 55 times

So the database is laid out very simply
ID term Count

I found a really clean function but I need to modify it and frankly arrays always have given me a bit of a headache.

function tagination( $baseURL, $tags, $cloud=true ) {
$tagination = ‘’;
if ( $cloud ) {
$minSize = 1; $maxSize = 10;
$maxTotal = max(array_values($tags));
$minTotal = min(array_values($tags));
$range = $maxTotal - $minTotal;
foreach ( $tags as $tagName => $tagTotal ) {
$fontSize = round($minSize + (($tagTotal - $minTotal) *
(($maxSize - $minSize) / $range)));
$tagTotal = number_format($tagTotal);
$tagURL = str_replace(’ ‘, ‘-’, $tagName);
$tagination .= “<a href=”{$baseURL}{$tagURL}" title="{$tagTotal}".
“articles” class=“size{$fontSize}”>{$tagName}\n";
} return $tagination;
} sort($tags);
foreach ( $tags as $tagName ) {
$tagURL = str_replace(’ ', ‘-’, $tagName);
$tagination .= “<a href=”{$baseURL}{$tagURL}" ".
"class=“tag”>{$tagName}, ";
} return substr($tagination, 0, strlen($tagination) - 2);

The CSS code to make it look right

body {font:62.5% arial, helvetica, sans-serif; font-style:normal}
div.cloud {text-align:justify; line-height:3em}
a.size1 {font-size:1.1em}
a.size2 {font-size:1.3em}
a.size3 {font-size:1.5em}
a.size4 {font-size:1.7em}
a.size5 {font-size:1.9em}
a.size6 {font-size:2.1em}
a.size7 {font-size:2.3em}
a.size8 {font-size:2.5em}
a.size9 {font-size:2.7em}
a.size10 {font-size:2.9em}

All the word cloud scripts have me counting an array when I am just going to pull the top 30 or so words based on count DESC LIMIT 0,30

What would be a simple

No one wants to tackle this?

The problem I have with standard word clouds is they assume your database is a sloppy mess or your working from text files all the time.

I mean if your running any real type of search to drop the term into a db and update the count +1 so constantly show examples of someone doing a word frequency count means that a bunch of people keep coping the guy who doesn’t run a real production setup.

So to pull a word cloud of my most frequent keywords I would just limit 0,10 the 10 highest count or I would and now will add TIME to last count update so I sort by Keywords updated by frequency within X(amount of time). That keeps my production site clean and fast I just need to work with the data I pull from a database not data I get from a test array.

Sponsor our Newsletter | Privacy Policy | Terms of Service