Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP][MYSQL]tag cloud , chmura znaczników .
Forum PHP.pl > Forum > Przedszkole
slewin
Znalazłem fajny skrypt chmury tagów
oto on
  1. <?php
  2. .tag_cloud { padding: 3px; text-decoration: none; }
  3. .tag_cloud:link  { color: #81d601; }
  4. .tag_cloud:visited { color: #019c05; }
  5. .tag_cloud:hover { color: #ffffff; background: #69da03; }
  6. .tag_cloud:active { color: #ffffff; background: #ACFC65; }
  7.  
  8. function get_tag_data() {
  9.  mysql_connect('localhost', 'root', '');
  10.  mysql_select_db('login');
  11.  $result = mysql_query(&#092;"SELECT * FROM tags GROUP BY tag ORDER BY count DESC\");
  12.  while($row = mysql_fetch_array($result)) {
  13.    $arr[$row['tag']] = $row['count'];
  14.  }
  15.  
  16.  return $arr;
  17. }
  18.  
  19.  
  20. function get_tag_cloud() {
  21. // podstawowe rozmiary czcionki
  22. $min_font_size = 10;
  23. $max_font_size = 20;
  24. $spread = 100;
  25.  
  26.  
  27. // Pull in tag data
  28. $tags = get_tag_data();
  29.  
  30.  
  31. //Finally we start the HTML building process to display our tags. For this demo the tag simply searches Google using the provided tag.
  32. $cloud_html = '';
  33. $cloud_tags = array(); // create an array to hold tag code
  34. foreach ($tags as $tag => $count) {
  35.    $size = round($min_font_size + ($count - $minimum_count) * ($max_font_size - $min_font_size) / $spread);
  36.    $cloud_tags[] = '
  37. }
  38.  
  39.  
  40.  
  41. $cloud_html = join(&#092;"\n\", $cloud_tags) . \"\n\";
  42. return $cloud_html;
  43. }
  44. ?>
  45.  
  46. Chmura tagów :


Problem : nie wiem gdzie wcisnąć kod do dodania kliknięcia w tag questionmark.gif
Chcialem dodać coś takiego ,ale to nie działa . ;/
  1. <?php
  2. if($_GET['fraza']=='$tag')
  3.            {
  4.            $row['count']++;
  5.            $id=$row['id'];
  6.            $count=$row['count'];
  7.            mysql_query("UPDATE tags SET count='$count' WHERE id='$id'");
  8. }
  9. ?>
Draz
  1. <?php
  2. function get_tag_data() {
  3.  mysql_connect('localhost', 'root', '');
  4.  mysql_select_db('login');
  5.  $result = mysql_query(&#092;"SELECT * FROM tags GROUP BY tag ORDER BY count DESC\");
  6.  while($row = mysql_fetch_array($result)) {
  7.  
  8. if($_GET['fraza']== $row['tag'])
  9.            {
  10.            $id=$row['id'];
  11.            mysql_query("UPDATE tags SET count=count+1 WHERE id='$id'");
  12. }
  13.  
  14.    $arr[$row['tag']] = $row['count'];
  15.  }
  16.  
  17.  return $arr;
  18. }
  19. ?>


Może tak będzie działać.
slewin
działa jak należy guitar.gif . THX
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.