Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [HTML][PHP] Chmurka tagów
gro0o
post
Post #1





Grupa: Zarejestrowani
Postów: 10
Pomógł: 0
Dołączył: 19.08.2012

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


Witam, mam problem z tagami, chciałbym to przerobić w sposób gdzie nazwa tagu miała taka samą wartość w linku, czyli Wyświetlony tag: Food, a odnośnik: index.php?search=food
by wartości brały się stąd:
Kod
$tags = array('weddings' => 32, 'birthdays' => 41, 'landscapes' => 62, 'ham' => 51, 'chicken' => 23, 'food' => 91, 'turkey' => 47, 'windows' => 82, 'apple' => 27);


cały kod:
Kod
<?
function printTagCloud($tags) {
        // $tags is the array
        
        arsort($tags);
        
        $max_size = 32; // max font size in pixels
        $min_size = 12; // min font size in pixels
        
        // largest and smallest array values
        $max_qty = max(array_values($tags));
        $min_qty = min(array_values($tags));
        
        // find the range of values
        $spread = $max_qty - $min_qty;
        if ($spread == 0) { // we don't want to divide by zero
                $spread = 1;
        }
        
        // set the font-size increment
        $step = ($max_size - $min_size) / ($spread);
        
        // loop through the tag array
        foreach ($tags as $key => $value) {
                // calculate font-size
                // find the $value in excess of $min_qty
                // multiply by the font-size increment ($size)
                // and add the $min_size set above
                $size = round($min_size + (($value - $min_qty) * $step));
        
                echo '<a href="index.php?search=' . ? ? ? .'" style="font-size: ' . $size . 'px" title="' . $value . ' things tagged with ' . $key . '">' . $key . '</a> ';
        }
}

$tags = array('weddings' => 32, 'birthdays' => 41, 'landscapes' => 62, 'ham' => 51, 'chicken' => 23, 'food' => 91, 'turkey' => 47, 'windows' => 82, 'apple' => 27);

printTagCloud($tags);
?>


Z góry dziękuję za pomoc smile.gif

Ten post edytował gro0o 1.09.2012, 10:23:27
Go to the top of the page
+Quote Post
nospor
post
Post #2





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




Cytat
a mianowicie nie wyświetlają się
To żaden opis problemu.

Zastosuj się proszę do tego
Temat: Jak poprawnie zada pytanie
A dostaniesz więcej informacji i wiecej nam będziesz mógł podać


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
gro0o
post
Post #3





Grupa: Zarejestrowani
Postów: 10
Pomógł: 0
Dołączył: 19.08.2012

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


@nospor poprawione

poradziłem sobie z tym smile.gif

Ten post edytował gro0o 1.09.2012, 10:33:57
Go to the top of the page
+Quote Post

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

 



RSS Aktualny czas: 20.08.2025 - 12:28