I'm trying to make a keyword cloud (like tagadelic) of embedded gallery2 keywords as a drupal page. The cloud works great but this code seems to break everything else besides the cloud on that page. Any advice would be greatly appreciated. As far as I could tell, gallery2 doesn't have an API for accessing keywords.
Drupal 4.7.5
Gallery 2.1.2
Apache 2
MySQL 4.1
<?php
function getCloud($minFont=10, $maxFont=35) {
$keyword = array();
$cloud = array();
$my_link = mysql_connect('localhost', 'user', 'pass')
or die('Could not connect: ' . mysql_error());
mysql_select_db('gallery2') or die('Could not select database');
// Grab the tags from the database
$keyword_query = mysql_query("SELECT g_keywords FROM g2_Item where g_keywords!=\"\" or g_keywords!=NULL ORDER BY RAND()");
while($t = mysql_fetch_array($keyword_query)) {
$key_db = explode('; ', $t[0]);
while(list($key, $value) = each($key_db)){
$keyword[$value] += 1;
}
}
// Get totals to use for font size
$min = min(array_values($keyword));
$max = max(array_values($keyword));
$fix = ($max - $min == 0) ? 1 : $max - $min;
// Display the tags
foreach ($keyword as $tag => $count) {
$size = $minFont + ($count - $min) * ($maxFont - $minFont) / $fix;