Ragazzi ho questo script per la tag cloud che non funziona ma non capisco qual'è il problema:
codice è questo
Codice PHP:
<?php
// Define user variables
$fontSizeUnit = "px";
$maxFontSize = 50;
$minFontSize = 12;
$tagsToDisplay = 50;
$tagDivider = "/"; // Leave blank for none
// Calculations
$fontSizeSpread = $maxFontSize - $minFontSize;
// Create a few blank arrays
$tagArray = array();
$tempTagArray = array();
// Connect to and query mySQL Database (NOTE: change "hostname," "username,"
// "password," and "databasename" to your information)
include ('config.php');
// Get all rows that don't have blank tags (NOTE: change "tablename" to your table)
$result = mysql_query("SELECT * FROM tag_tbiz WHERE tag!=''");
// Loop through each result of the query
while($row = mysql_fetch_array($result)){
// Split the result of each query ", " (our tags will be in the form "tag 1,
// tag 2, tag 3" etc.) and store the results to an array
$tempStringArray = preg_split("/, /", $row["tag"]);
// Loop through all items of this string array (i.e. loop through each tag)
// Use a "for" loop
for ($a = 0; $a < count($tempStringArray); $a++) {
// Convert to lowercase
$tempStringArray[$a] = strtolower($tempStringArray[$a]);
// Check if it exists in tag array
if ($tagArray[$tempStringArray[$a]] == '') {
// If it doesn't exist, create it with value 1
$tagArray[$tempStringArray[$a]] = 1;
} else {
// If it does exist, increase the value by 1
$tagArray[$tempStringArray[$a]] += 1;
}
}
}
// Store to temporary array to be used to choose the top tags, then sort
// temporary array according to tag value, descending
arsort($tagArray);
$numberOfTags = 0;
foreach ($tagArray as $key => $val) {
$numberOfTags++;
if ($numberOfTags > $tagsToDisplay) {
break;
}
$finalTagArray[$key] = $val;
}
ksort($finalTagArray);
$maxTagCount = max($finalTagArray);
$minTagCount = min($finalTagArray);
$tagCountSpread = $maxTagCount - $minTagCount;
$unitsPerCount = $fontSizeSpread/$tagCountSpread;
// Function to calculate the font size
function calcSize($thisTagCount) {
// Import necessary global variables
global $minTagCount, $minFontSize, $fontSizeUnit, $unitsPerCount;
// Calculate the font size
$thisFontSize = $minFontSize+($unitsPerCount*($thisTagCount-$minTagCount));
// Round the font size and add units
$thisFontSize = round($thisFontSize) . $fontSizeUnit;
// Return the font size
return $thisFontSize;
}
$b = 1;
foreach ($finalTagArray as $key => $val) {
echo "<span style='font-size: ";
echo calcSize($val);
echo "'>" . $key . "</span>";
if ($b != count($finalTagArray)) {
echo " " . $tagDivider . " ";
}
$b++;
}
?>
l'errore che mi da è :
Warning: Division by zero in /web/htdocs/technologybiz.eu/home/prova2.php on line 65
corrispondente a questo:
$unitsPerCount = $fontSizeSpread/$tagCountSpread;
ringrazio in anticipo per l'aiuto