Mailinglisten-Archive |
Michi wrote:
> Hallo Leute,
>
> Ich brauche eure Hilfe.
>
> Habe eine Webseite mit Preislisten in Tabellen form die ich als cvs einlese,
> das geht auch alles nur will ich jede 2te zeile ein farbwechsel haben so
> ähnlich wie hier beschrieben
> http://www.selfphp.de/kochbuch/kochbuch.php?code=31
>
> nur ich bekomme das nicht hin.
>
> hier mein code:
>
> <?php
>
> $csvfile = fopen ($DateiMOD,"r");
> $row = 1;
> print "<table border='1' width='99%' align='center' class='tableLine'>
> <col width=50>
> <col width=100>
> <col width=100>
> <col width=100>
> <col width=100>
> <col width=150>
> <col width=100>
> <col width=90>\n";
> print "<tr align='center'>
> <td><b>Lfd Nr. </b></td>
> <td><b>Waffentyp</b> </td>
> <td><b>Kaliber</b> </td>
> <td><b>Beschreibung</b> </td>
> <td><b>Beurteilung</b> </td>
> <td><b>Sonstige</b> </td>
> <td><b>Waffenbuch</b> </td>
> <td><b>Preis </b></td>
> </tr>\n";
> while ( ($data = fgetcsv ($csvfile, 200, ";")) !== FALSE ) {
> if (trim($data[7]) == $ABFRAGE) {
> printf ("<tr class=row_".$row.">
> <td>".$row."- </td>
> <td>".$data[0]." </td>
> <td>".$data[1]." </td>
> <td>".$data[2]." </td>
> <td>".$data[3]." </td>
> <td>".$data[4]." </td>
> <td>".$data[5]." </td>
> <td>".$data[6]." </td>
> </tr>\n",$row%2);
> $row++;
>
> }
> }
> fclose ($csvfile);
> print '</table>';
> ?>
>
> Was mache ich Falsch?
> In dem Beispiel wurde was von Modulo geschrieben? In meinen PHP Büchern ist
> nix wirklich darüber zu finden.
>
> Danke im Voraus, wünsche euch ein Nettes Wochenende?
>
>
>
Du hast halt nen Counter ($row in deinem Beispiel) der bei jeder Reihe
um 1 erhöht wird.
Ja und dann prüfst du halt einfach:
if ($row%2 == 0) {
// die eine farbe
} else {
// die andere farbe
}
Modulo gibt den Ganzzahligen Rest einer Division zurück.
MfG Jay
--
My system configuration (Gentoo Linux): http://www.linux-stats.org/index.php?c=userpage&sys=810
Registered Linux User #373457
php::bar PHP Wiki - Listenarchive