include("headerCurl.php");?> // http://prism-perfect.net/archive/php-tag-cloud-tutorial/ //$emotionOrdered = "SELECT emotion AS tag, COUNT(emotion) AS quantity FROM webEmotion GROUP BY emotion ORDER BY quantity DESC"; $emotionOrdered = "SELECT Emotions.emotion AS tag, Emotions.colour, COUNT(webEmotion.emotion) AS 'quantity' FROM webEmotion INNER JOIN Emotions ON Emotions.emotion = webEmotion.emotion GROUP BY webEmotion.emotion"; $result = mysql_query($emotionOrdered); // here we loop through the results and put them into a simple array: // $tag['thing1'] = 12; // $tag['thing2'] = 25; // etc. so we can use all the nifty array functions // to calculate the font-size of each tag while ($row = mysql_fetch_array($result)) { $tags[$row['tag']] = $row['quantity']; } // change these font sizes if you will $max_size = 200; // max font size in % $min_size = 80; // min font size in % // get the largest and smallest array values $max_qty = max(array_values($tags)); $min_qty = min(array_values($tags)); $spread = $max_qty - $min_qty; if (0 == $spread) { // we don't want to divide by zero $spread = 1; } // determine the font-size increment // this is the increase per tag quantity (times used) $step = ($max_size - $min_size)/($spread); ?>