imarockstar Posted August 20, 2008 Share Posted August 20, 2008 Ok I have posted this b4 . well sortof .... I changed my code and its still not working ... so I starting from fresh ... This is what I want the TAG CLOUD to do. I want the tag cloud to pull the tags ($tag) and the tags description ($desc) from the database and display them on the front page of my site. As of right now it is only pulling the tag ($tag) and the tag count ($count) As you can see there are two (2) fuctions that make up this tag cloud : function tag_info() { $result = m_q("SELECT * FROM pic_tags GROUP BY tag ORDER BY RAND() LIMIT 20"); while($row = mysql_fetch_array($result)) { // add both data to returned array $arr[$row['tag']] = array($row['count'], $row['desc']); } ksort($arr); return $arr; } function tag_cloud() { $min_size = 10; $max_size = 30; $tags = tag_info(); foreach ($tags as $t) $tags1[] = $t[0]; $minimum_count = min($tags1); $maximum_count = max($tags1); $spread = $maximum_count - $minimum_count; if($spread == 0) { $spread = 1; } $cloud_html = ''; $cloud_tags = array(); foreach ($tags as $tag => $count) { $size = $min_size + ($count[0] - $minimum_count) * ($max_size - $min_size) / $spread; //change output to $count[0](count) and $count[](description) //add ending a tag $cloud_tags[] = '<a style="font-size: '. floor($size) . 'px' . '" class="tag_cloud" title=" '. $desc .' " href="tagedphoto.php?tag=' . $tag . ' ">' . htmlspecialchars(stripslashes($tag)) . '</a>'; } $cloud_html = join("\n", $cloud_tags) . "\n"; return $cloud_html; } As you can see by the code, I am trying to display the tag ($tag) description ($desc) within the title attribute of the link. Can anyone tell me what I am doing wrong ? here is the link to the working tag cloud .. http://franklinspirko.com/sites/dwf/ Quote Link to comment https://forums.phpfreaks.com/topic/120552-solved-tag-cloud-help-please-b4-i-shoot-myself/ Share on other sites More sharing options...
imarockstar Posted August 20, 2008 Author Share Posted August 20, 2008 please help ... my cloud is fading !!!!! lol Quote Link to comment https://forums.phpfreaks.com/topic/120552-solved-tag-cloud-help-please-b4-i-shoot-myself/#findComment-621366 Share on other sites More sharing options...
akitchin Posted August 20, 2008 Share Posted August 20, 2008 you're not defining $desc - you need to either define it or use $count[1] directly. Quote Link to comment https://forums.phpfreaks.com/topic/120552-solved-tag-cloud-help-please-b4-i-shoot-myself/#findComment-621380 Share on other sites More sharing options...
imarockstar Posted August 20, 2008 Author Share Posted August 20, 2008 Ok awsome .. um ... Not sure how to do that ? I didnt write this script I got it from a tutorial and added some .... coul dyou pinpoint in my code what to do by any chance ? b Quote Link to comment https://forums.phpfreaks.com/topic/120552-solved-tag-cloud-help-please-b4-i-shoot-myself/#findComment-621389 Share on other sites More sharing options...
Lamez Posted August 20, 2008 Share Posted August 20, 2008 He means define the variable, and I am guessing that is what it needs to be. <?php $desc = $row['desc']; ?> Quote Link to comment https://forums.phpfreaks.com/topic/120552-solved-tag-cloud-help-please-b4-i-shoot-myself/#findComment-621395 Share on other sites More sharing options...
akitchin Posted August 20, 2008 Share Posted August 20, 2008 this section: foreach ($tags as $tag => $count) { $size = $min_size + ($count[0] - $minimum_count) * ($max_size - $min_size) / $spread; //change output to $count[0](count) and $count[](description) //add ending a tag $cloud_tags[] = '<a style="font-size: '. floor($size) . 'px' . '" class="tag_cloud" title=" '. $desc .' " href="tagedphoto.php?tag=' . $tag . ' ">' . htmlspecialchars(stripslashes($tag)) . '</a>'; } uses $desc, but it hasn't been assigned anywhere. substitute $count[1] for $desc in that block. Quote Link to comment https://forums.phpfreaks.com/topic/120552-solved-tag-cloud-help-please-b4-i-shoot-myself/#findComment-621397 Share on other sites More sharing options...
imarockstar Posted August 20, 2008 Author Share Posted August 20, 2008 so what would change here function tag_info() { $result = m_q("SELECT * FROM pic_tags GROUP BY tag ORDER BY RAND() LIMIT 20"); while($row = mysql_fetch_array($result)) { // add both data to returned array $arr[$row['tag']] = array($row['count'], $row['desc']); } ksort($arr); return $arr; } Quote Link to comment https://forums.phpfreaks.com/topic/120552-solved-tag-cloud-help-please-b4-i-shoot-myself/#findComment-621412 Share on other sites More sharing options...
imarockstar Posted August 20, 2008 Author Share Posted August 20, 2008 ok i figured it out .. thnks for the help guys !!!! Quote Link to comment https://forums.phpfreaks.com/topic/120552-solved-tag-cloud-help-please-b4-i-shoot-myself/#findComment-621418 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.