Welcome Guest, Not a member yet? Register   Sign In
Create a tag cloud (kind of)
#11

[eluser]iDenta[/eluser]
waldmeister: There we have it! Now it is working as i wanted it to, thanks!

All there is to do now is to make it look like a tag cloud, so that the font size changes according to have many times each word occurs.

I made a simple test with if blabla then font-size: 16px; like:

Code:
if ($row->total < '10')
{
  echo '<span style="font-size: 10px;">'.$row->word_list.'</span>&nbsp;&nbsp;';
}
elseif ($row->total > '20')
{
  echo '<span style="font-size: 16px;">'.$row->word_list.'</span>&nbsp;&nbsp;';
}

And, although it works, there must be some better way to do this... I had a look in the code for FreeTag, but couldn't figure out a better way to do it.

Did i say i'm a newbie at this? Smile
#12

[eluser]drewbee[/eluser]
Why not have the font size increase based on the views? Lets say for only 1 occurance of a word, you will display it at 10px up to a maximum of 30px

Code:
$base = 10; // 10 px
$max = 30; // 30 px
$size = $base * $row->total;

if ($size > $max)
{
    $size = $max;
}
echo '<span style="font-size: ' . $size . 'px;">' . $row->word_list . '</span>&nbsp;&nbsp;';

There you go. you have a dynamically changing font size based on word count just by using simple math with a minimum of 10 px and a maximum of 30px




Theme © iAndrew 2016 - Forum software by © MyBB