Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][MYSQL]tag cloud , chmura znaczników ., chce aby po kliknieciu na tag dodalo +1 do bazy danych
slewin
post
Post #1





Grupa: Zarejestrowani
Postów: 104
Pomógł: 7
Dołączył: 9.12.2008
Skąd: wroc

Ostrzeżenie: (0%)
-----


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 (IMG:http://forum.php.pl/style_emoticons/default/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. ?>


Ten post edytował slewin 20.02.2009, 11:22:29
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 2)
Draz
post
Post #2





Grupa: Zarejestrowani
Postów: 7
Pomógł: 1
Dołączył: 11.02.2009

Ostrzeżenie: (0%)
-----


  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ć.
Go to the top of the page
+Quote Post
slewin
post
Post #3





Grupa: Zarejestrowani
Postów: 104
Pomógł: 7
Dołączył: 9.12.2008
Skąd: wroc

Ostrzeżenie: (0%)
-----


działa jak należy (IMG:http://forum.php.pl/style_emoticons/default/guitar.gif) . THX
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.08.2025 - 14:04