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
eurosoft
post 9.11.2010, 12:25:16
Post #3





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

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


Cytat(CuteOne @ 9.11.2010, 11:46:21 ) *
  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';


mam teraz coś takiego, niestety wytryna wogóle się nie otwiera...sad.gif
  1. {
  2. echo "<table border=1 cellspacing=2 cellpadding=0 bgcolor=#CCCCCC bordercolor=#a7a7a7>";
  3.  
  4.  
  5. echo "<tr>";
  6. echo "<th>L.p.</th>";
  7. echo "<th>Imię i Nazwisko</th>";
  8. echo "<th>Nr odstrzału</th>";
  9. echo "<th>Miejsce wykon. polowania</th>";
  10. echo "<th>Data rozp. polowania</th>";
  11. echo "<th>Godz rozp. polowania</th>";
  12. echo "<th>Osoba dokonująca wpisu elektr.</th>";
  13. echo "<th>Data zakończ. polowania</th>";
  14. echo "<th>Godz zakończ. polowania</th>";
  15. echo "<th>Gatunek poz. zwierzyny</th>";
  16. echo "<th>Ilość poz zwierzyny</th>";
  17. echo "<th>Osoba dokonująca wpisu elektr.</th>";
  18. echo "<th>Ilość strzałów</th>";
  19. echo "<th>Info</th>";
  20.  
  21.  
  22. $i = 0;
  23.  
  24. while($r = mysql_fetch_array($result) AND $z = mysql_fetch_array($result1))
  25.  
  26.  
  27. {
  28. echo "<tr>";
  29. echo '<tr style="background:'.getBg($i++).'">';
  30. echo "<td width=40 align=center>".$r[0]."</td>";
  31. echo "<td width=140>".$r[1]."</td>";
  32. echo "<td width=50 align=center>".$r[2]."</td>";
  33. echo "<td width=60 align=center>".$r[3]."</td>";
  34. echo "<td width=140>".$r[4]."</td>";
  35. echo "<td width=140 align=center>".$r[5]."</td>";
  36. echo "<td width=140>".$r[6]."</td>";
  37. echo "<td width=150 align=center>".$r[7]."</td>";
  38. echo "<td width=50 align=center>".$r[8]."</td>";
  39. echo "<td width=140 align=center>".$z[3]."</td>";
  40. echo "<td width=140 align=center>".$z[4]."</td>";
  41. echo "<td width=140 align=center>".$z[6]."</td>";
  42. echo "<td width=140 align=center>".$z[5]."</td>";
  43. echo "<td><a href=\"ewidencja.php?a=edit&amp;id_book={$r[0]}\" >ZMIEŃ</a></td>";
  44. echo "</tr>";
  45. }
  46. FUNCTION getBg($i) RETURN ($i%2==1) ? 'green' : 'red';
  47. echo "</table>";
  48.  
  49. }


Ten post edytował eurosoft 9.11.2010, 12:40:49
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:56