Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Przemienne kolorowanie rekordów w tabeli
eurosoft
post 9.11.2010, 11:39:45
Post #1





Grupa: Zarejestrowani
Postów: 179
Pomógł: 0
Dołączył: 5.11.2010

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


Kurcze nie wiem co sie stało, ale mój ostatni post zniknął, proszę o porade jak zrobic zkrypt aby rekordy w tabeli miały różny kolor
  1. echo "<th>Osoba</th>";
  2. echo "<th>Ilość</th>";
  3. echo "<th>Info</th>";
  4.  
  5.  
  6.  
  7.  
  8. while($r = mysql_fetch_array($result) AND $z = mysql_fetch_array($result1))
  9.  
  10.  
  11. {
  12. echo "<tr>";
  13. echo "<td width=40 align=center>".$r[0]."</td>";
  14. echo "<td width=140>".$r[1]."</td>";
  15. echo "<td width=50 align=center>".$r[2]."</td>";
  16. echo "<td width=60 align=center>".$r[3]."</td>";
  17. echo "<td width=140>".$r[4]."</td>";
  18.  


TX
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
CuteOne
post 9.11.2010, 11:46:21
Post #2





Grupa: Zarejestrowani
Postów: 2 958
Pomógł: 574
Dołączył: 23.09.2008
Skąd: wiesz, że tu jestem?

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


  1. $i = 0;
  2. while($r = mysql_fetch_array($result) AND $z = mysql_fetch_array($result1))
  3. {
  4. echo '<tr style="background:'.getBg($i++).'">';
  5. echo "<td width=40 align=center>".$r[0]."</td>";
  6. echo "<td width=140>".$r[1]."</td>";
  7. echo "<td width=50 align=center>".$r[2]."</td>";
  8. echo "<td width=60 align=center>".$r[3]."</td>";
  9. echo "<td width=140>".$r[4]."</td>";
  10. }
  11.  
  12. function getBg($i) return ($i%2==1) ? 'green' : 'red';


Ten post edytował CuteOne 9.11.2010, 11:46:47
Go to the top of the page
+Quote Post

Posty w temacie


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: 14.08.2025 - 19:01