Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP] Kolor czcionki w zależności od zmiennej
kactuzz
post 17.02.2009, 17:18:47
Post #1





Grupa: Zarejestrowani
Postów: 12
Pomógł: 0
Dołączył: 28.07.2006

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


Mam sobie tam jakas zmienna, np $wygrana.
Dodałem taki warunek:

  1. <?php
  2. if ($wygrana<0)
  3. {
  4. $kolor1="red"
  5. }
  6. else
  7. {
  8. $kolor1="green"
  9. }
  10. ?>


No i dodałem w odpowiednim miejscu dałem <font color="$color"> i nie dziala, otwiera sie pusta strona..


--------------------
Go to the top of the page
+Quote Post
Spawnm
post 17.02.2009, 17:19:52
Post #2





Grupa: Moderatorzy
Postów: 4 069
Pomógł: 497
Dołączył: 11.05.2007
Skąd: Warszawa




$kolor1="green"
a gdzie ';'
$kolor1="green"; powinno być...
Go to the top of the page
+Quote Post
Foxx
post 17.02.2009, 17:22:00
Post #3





Grupa: Zarejestrowani
Postów: 896
Pomógł: 76
Dołączył: 15.11.2003
Skąd: Sosnowiec/Kraków

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


Zmienna to $kolor1 a nie $color więc jak już coś to:
  1. <font color="<?php echo $kolor1; ?>">
Go to the top of the page
+Quote Post
kactuzz
post 17.02.2009, 18:50:32
Post #4





Grupa: Zarejestrowani
Postów: 12
Pomógł: 0
Dołączył: 28.07.2006

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


Buehe jak moglem taki podstawowy blad zrobic haha.gif
A ten $color to literowka byla.

Aha no tylko nie za bardzo mi sie chce to "zgrac":

  1. <?php
  2. echo ("
  3. <html>
  4. <head>
  5. <LINK REL='stylesheet' HREF='style.css' TYPE='text/css'>
  6. <title>Kalkulator</title>
  7. </head>
  8. <body>
  9.  
  10. <table class='tabela' align='center'>
  11. <tr><td class='kom1' align='center' width='300'>Mecze</td><td class='kom1' align='center' width='50'>Kurs</td><td class='kom1' align='center' width='50'>Wygrana</td><td class='kom1' align='center' width='50'>Profit</td></tr>
  12. <tr class='kom2'><td class='kom3'>$a<br>$b</td><td class='kom3' align='center'>$wiersz1</td><td class='kom3' align='center'>$wygrana1</td><td class='kom3' align='center'><font color="<?php echo $kolor1; ?>">");
  13. echo ("$profit1</font></td></tr>
  14. <tr class='kom2'><td class='kom3'>$a<br>$c</td><td class='kom3' align='center'>$wiersz2</td><td class='kom3' align='center'>$wygrana2</td><td class='kom3' align='center'><font color="<?php echo $kolor2; ?>">");
  15. echo ("$profit2</font></td></tr>
  16. <tr class='kom2'><td class='kom3'>$b<br>$c</td><td class='kom3' align='center'>$wiersz3</td><td class='kom3' align='center'>$wygrana3</td><td class='kom3' align='center'><font color="<?php echo $kolor3; ?>">");
  17. echo ("$profit3</font></td></tr>
  18. </table>
  19.  
  20. ?>

Bo sami widzicie jak jest :/
Noob dalej ejstem hehe

Ten post edytował kactuzz 17.02.2009, 18:52:08


--------------------
Go to the top of the page
+Quote Post
DREEMus
post 17.02.2009, 18:57:14
Post #5





Grupa: Zarejestrowani
Postów: 286
Pomógł: 34
Dołączył: 4.09.2008
Skąd: Wrocław

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


Dlaczego używasz apostrofów zamiast cudzysłowów questionmark.gif

linia 11 ...
  1. <?php
  2. <tr class='kom2'><td class='kom3'>$a<br>$b</td><td class='kom3' align='center'>$wiersz1</td><td class='kom3' align='center'>$wygrana1</td><td class='kom3' align='center'><font color="$kolor1">$profit1</font></td></tr>
  3. <tr class='kom2'><td class='kom3'>$a<br>$c</td><td class='kom3' align='center'>$wiersz2</td><td class='kom3' align='center'>$wygrana2</td><td class='kom3' align='center'><font color="$kolor2">$profit2</font></td></tr>
  4. <tr class='kom2'><td class='kom3'>$b<br>$c</td><td class='kom3' align='center'>$wiersz3</td><td class='kom3' align='center'>$wygrana3</td><td class='kom3' align='center'><font color="$kolor3">$profit3</font></td></tr>
  5. </table>";
  6. ?>


i czemu używasz "echo" skoro inne zmienne wstawiasz bez niego questionmark.gif


--------------------
Serwer : Acer Aspire 5050 : AMD Turion X2 2x1.9 MHz : 2x2 GB Dual : 250GB + 500 GB USB
Warsztat : Apache v2.2 : PHP v5.2 : MySQL v5.0 : phpMyAdmin v3.4 : phpDesigner v7
Go to the top of the page
+Quote Post
kactuzz
post 17.02.2009, 19:07:20
Post #6





Grupa: Zarejestrowani
Postów: 12
Pomógł: 0
Dołączył: 28.07.2006

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


Bauahah no niedoczytałem i glupi jestem biggrin.gif

\" sie kłania biggrin.gif

Ten post edytował kactuzz 17.02.2009, 19:07:39


--------------------
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 Wersja Lo-Fi Aktualny czas: 24.07.2025 - 23:31