Jump to content

[SOLVED] mysql counting data


dtdetu

Recommended Posts

hello i have this function to generate tag clouds in my site

 

<?php
function tag_cloud($tags) {
    $maxsize = 40;
    $minsize = 20;

    $maxval = max(array_values($tags));
    $minval = min(array_values($tags));

    $spread = $maxval - $minval;

    $step = ($maxsize - $minsize) / ($spread);

    foreach ($tags as $key => $value) {
        $size = round($minsize + (($value - $minval) * $step));
        echo '<a href="#" style="font-size: '.$size.'px">'.$key.'</a> ';
    }
}

$tags = array('php'=>30, 'javascript'=>24, 'java'=>17, 'python'=>26, 'ruby'=>17);

tag_cloud($tags);

 

i will use it as search tag cloud generator, in my database there are search keywords. my searches stored invidually , so i think i need to use group by in the query.

 

but i couldnt figure how can i get data from mysql and use in this function. Can someone help me please

Link to comment
https://forums.phpfreaks.com/topic/163051-solved-mysql-counting-data/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.