Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Przemienne kolory rekordów w tabeli
eurosoft
post
Post #1





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

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


w jaki sposób można zrobić przemienne kolorowanie kolejnych rekordów w tabeli?
Poniżej fragment kodu generującego tabelę:

  1. ...
  2. echo "<th>Ilość</th>";
  3. echo "<th>Osoba wpisująca</th>";
  4. echo "<th>Info</th>";
  5.  
  6. while($r = mysql_fetch_array($result) and $z = mysql_fetch_array($result1))
  7.  
  8. {
  9. echo "<tr>";
  10. echo "<td width=40 align=center>".$r[0]."</td>";
  11. echo "<td width=140>".$r[1]."</td>";
  12. echo "<td width=50 align=center>".$r[2]."</td>";
  13. echo "<td width=60 align=center>".$r[3]."</td>";
  14.  
  15. ....


Ten post edytował eurosoft 9.11.2010, 09:01:16
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
norbis
post
Post #2





Grupa: Zarejestrowani
Postów: 42
Pomógł: 8
Dołączył: 30.04.2008

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


Koledzy dobrze kombinują, ale można jeszcze uprościć (IMG:style_emoticons/default/winksmiley.jpg)

  1. $i=0;
  2. while($r = mysql_fetch_array($result) and $z = mysql_fetch_array($result1)){
  3. $i++;
  4. echo '<tr style="'.($i%2==0?'background-color: red;':'background-color: green;').'">';
  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. }


Ten post edytował norbis 9.11.2010, 09:18:14
Go to the top of the page
+Quote Post

Posty w temacie


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: 8.10.2025 - 13:54