arkadaşlar br yerden bulduğum etiket bulutu scripti var ve onu kullanmak istiyorum ama bir değişiklik yapmak istiyorum.
tablo şu şekilde
CREATE TABLE tags (
id int(11) NOT NULL,
tag varchar(100) NOT NULL,
count int(11) NOT NULL DEFAULT '0'
);
insert into tags values ('','php','50');
insert into tags values ('','ajax','60');
insert into tags values ('','mysql','80');
insert into tags values ('','erdem','250');
insert into tags values ('','gulce','250');
insert into tags values ('','cenk','100');
insert into tags values ('','mustafa','78');
insert into tags values ('','ozan','32');
benim yapmak istediğim. diğelim php etiketi altına yazılar girilecek. kaç tane yazı girilmişse tablodaki
count değeri ona göre artıcak. tabiböyle birşey olmaz. herhalde şöyle olacak. bir tablo daha oluşturacam.
mesela
create table icerik (
id int primary key auto_increment
tags_id int,
yazi text
);
ilk verdiğim tabloda da count stünu icerik_id olarak değiştirilebilir. ardından icerik tablosundaki tags_id stünu sayılarak kaç tane aynı değer varsa (mesela php nin id değeri 1) tags_id de kaç tane 1 varsa onu icerik tablosunda icerik_id ye kaydedebilirim. tabi bu bu scripte göre planladığım birşey. başka fikriniz varsa lütfen paylaşın.
buda script
<?php
function get_tag_data() {
mysql_connect('localhost', 'root', '');
mysql_select_db('deneme');
$result = mysql_query("SELECT * FROM tags GROUP BY tag ORDER BY count DESC");
while($row = mysql_fetch_array($result)) {
$arr[$row['tag']] = $row['count'];
}
ksort($arr);
return $arr;
}
function get_tag_cloud() {
// Default font sizes
$min_font_size = 12;
$max_font_size = 30;
// Pull in tag data
$tags = get_tag_data();
$minimum_count = min(array_values($tags));
$maximum_count = max(array_values($tags));
$spread = $maximum_count - $minimum_count;
if($spread == 0) {
$spread = 1;
}
$cloud_html = '';
$cloud_tags = array(); // create an array to hold tag code
foreach ($tags as $tag => $count) {
$size = $min_font_size + ($count - $minimum_count)
* ($max_font_size - $min_font_size) / $spread;
$cloud_tags[] = '<a style="font-size: '. floor($size) . 'px'
. '" class="tag_cloud" href="http://www.google.com/search?q=' . $tag
. '" title="\'' . $tag . '\' returned a count of ' . $count . '">'
. htmlspecialchars(stripslashes($tag)) . '</a>';
}
$cloud_html = join("\n", $cloud_tags) . "\n";
return $cloud_html;
}
?>
<style type="text/css">
.tag_cloud { padding: 3px; text-decoration: none; }
.tag_cloud:link { color: #81d601; }
.tag_cloud:visited { color: #019c05; }
.tag_cloud:hover { color: #ffffff; background: #69da03; }
.tag_cloud:active { color: #ffffff; background: #ACFC65; }
</style>
<h3>Sample Tag Cloud results</h3>
<div id="wrapper">
<!-- BEGIN Tag Cloud -->
<?php
// Display the Tag Cloud in an HTML format
print get_tag_cloud();
?>
<!-- END Tag Cloud -->
</div>