|
|||
Bestimmte Websiteinhalte farblich markieren
Hallo zusammen.
Ich habe eine index.php die eine CSV Datei wiederspiegelt. Code:
<?php // CSV-Datei in eine HTML-Tabelle auslesen $daten = file("http://www.beispielseitentext.de/meinedatei.csv", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); echo '<table border>'; foreach ($daten as $nr => $data) { list($spalte1, $spalte2, $spalte3, $spalte4, $spalte5, $spalte6, $spalte7, $spalte8, $spalte9, $spalte10, $spalte11, $spalte12, $spalte13, $spalte14, $spalte15, $spalte16, $spalte17) = explode(";", $data); // ; Trennzeichen if ($nr == 0) { echo '<tr><th>' . $spalte1 . '</th><th>' . $spalte2 . '</th><th>' . $spalte3 . '</th><th>' . $spalte4 . '</th><th>' . $spalte5 . '</th><th>' . $spalte6 . '</th><th>' . $spalte7 . '</th><th>' . $spalte8 . '</th><th>' . $spalte9 . '</th><th>' . $spalte10 . '</th><th>' . $spalte11 . '</th><th>' . $spalte12 . '</th><th>' . $spalte13 . '</th><th>' . $spalte14 . '</th><th>' . $spalte15 . '</th><th>' . $spalte16 . '</th><th>' . $spalte17 . '</th>'; } else { echo '<tr><td>' . $spalte1 . '</td><td>' . $spalte2 . '</td><td>' . $spalte3 . '</td><td>' . $spalte4 . '</td><td>' . $spalte5 . '</td><td>' . $spalte6 . '</td><td>' . $spalte7 . '</td><td>' . $spalte8 . '</td><td>' . $spalte9 . '</td><td>' . $spalte10 . '</td><td>' . $spalte11 . '</td><td>' . $spalte12 . '</td><td>' . $spalte13 . '</td><td>' . $spalte14 . '</td><td>' . $spalte15 . '</td><td>' . $spalte16 . '</td><td>' . $spalte17 . '</td>'; } } echo '</table>'; ?> Beispiel 179 und würde dann per CSS die ganze Zeile Fablich in Rot markieren lassen. Danke für eure Hilfe, wenn es klappt. |
Sponsored Links |
|
|||
So.
konnte das hier umsetzen: Code:
<?php $spalte6 = str_replace('101', '<font style="color: #FE2E2E;">101</font>', $spalte6); $spalte5 = str_replace('101', '<font style="color: #FFF;background-color:#FE2E2E;font-weight:bold;">TEST</font>', $spalte6); Beispiel: Variante 1 Suche nach 101 funktioniert Ergebnis = TEST Variante 2 Suche nach 101 = TEST und weitere Suche 332 = TEST2 Da sollen noch mehr varianten rein. Habe versucht die Suche untereinander nochmal rein zu kopieren... Klappt aber nicht. Code:
$spalte6 = str_replace('101', '<font style="color: #FE2E2E;">101</font>', $spalte6); $spalte5 = str_replace('101', '<font style="color: #FFF;background-color:#FE2E2E;font-weight:bold;">TEST</font>', $spalte6); $spalte6 = str_replace('332', '<font style="color: #FE2E2E;">332</font>', $spalte6); $spalte5 = str_replace('332', '<font style="color: #FFF;background-color:#FE2E2E;font-weight:bold;">TEST2</font>', $spalte6); Danke Geändert von asncm (22.04.2021 um 23:13 Uhr) |
|
|||
Verwende niemals <font> Tags. Außer du bist im Jahre 1990 stecken geblieben.
Wie gesagt, zuerst musst du eine Klasse vergeben: Code:
$class = $spalte1 == 100 ? 'class="highlight"' : ''; echo '<tr><td '. $class .'>' .... Im CSS schreibst du dann: Code:
.highlight { background-color: green; /* Hier die Styles einfügen die du wirklich brauchst und nicht die HG Farbe auf grün setzen*/ } |
|
|||
Hallo nochmal.
Irgendwie bekomme ich das ding nicht zum laufen.... Wenn ich deinen Code eingefügt habe lief Garnichts mehr. Habe das jetzt so gemacht: CSS: Code:
<style type="text/css"> table, th, td { border-collapse: collapse; padding: .3em .5em; } table { margin-left: 1em;} th, caption { background-color: #FE2E2E; color: #fff; border: thin solid #666; } td { background-image: linear-gradient(#f9f9f9, #e3e3e3); border-left: thin solid #666; border-right: thin solid #666; } tfoot { border-bottom: thin solid #666; } caption { font-size: 1.5em; border-radius: .5em .5em 0 0; padding: .5em 0 0 0 } .highlight { background-color: #FE2E2E; } </style> Code:
<?php // CSV-Datei in eine HTML-Tabelle auslesen $daten = file("http://www.beispielseitentext.de/meinedatei.csv", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); echo '<table border>'; foreach ($daten as $nr => $data) { list($spalte1, $spalte2, $spalte3, $spalte4, $spalte5, $spalte6, $spalte7, $spalte8, $spalte9, $spalte10, $spalte11, $spalte12, $spalte13, $spalte14, $spalte15, $spalte16, $spalte17) = explode(";", $data); // ; Trennzeichen if ($nr == 0) { echo '<tr><th>' . $spalte1 . '</th><th>' . $spalte2 . '</th><th>' . $spalte3 . '</th><th>' . $spalte4 . '</th><th>' . $spalte5 . '</th><th>' . $spalte6 . '</th><th>' . $spalte7 . '</th><th>' . $spalte8 . '</th><th>' . $spalte9 . '</th><th>' . $spalte10 . '</th><th>' . $spalte11 . '</th><th>' . $spalte12 . '</th><th>' . $spalte13 . '</th><th>' . $spalte14 . '</th><th>' . $spalte15 . '</th><th>' . $spalte16 . '</th><th>' . $spalte17 . '</th>'; } else { $class = $spalte6 == 101 ? $class=$spalte5="highlight" : $spalte6; echo '<tr><td>' . $spalte1 . '</td><td>' . $spalte2 . '</td><td>' . $spalte3 . '</td><td>' . $spalte4 . '</td><td>' . $spalte5 . '</td><td>' . $spalte6 . '</td><td>' . $spalte7 . '</td><td>' . $spalte8 . '</td><td>' . $spalte9 . '</td><td>' . $spalte10 . '</td><td>' . $spalte11 . '</td><td>' . $spalte12 . '</td><td>' . $spalte13 . '</td><td>' . $spalte14 . '</td><td>' . $spalte15 . '</td><td>' . $spalte16 . '</td><td>' . $spalte17 . '</td>'; } } echo '</table>'; ?> So sollte es eigentlich aussehen: Mit PHP muss ich mich erst einmal anfreunden. Minimale Sachen konnte ich schon umsetzen. Leider stehe ich hier bei einem Rätsel. |
|
||||
Ich würde es so versuchen
http://sebastian1012.bplaced.net/tes...rben/index.php |
|
|||
Das ist keine Fehlerbeschreibung. Entweder es fliegt ein Fehler im PHP Teil oder die Ausgabe ist zwar da, aber nicht korrekt gerendert. Oder irgendetwas anderes.
Ansonsten kann ich nur wiederholen was ich schon dreimal geschrieben habe: Du brauchst eine Klasse welche du dann im CSS ansprichst: Code:
<td class="deine-klasse"> 192389023 </td> .deine-klasse {background-color: pink} Auch frage ich mich warum hier nicht mit einem array gearbeitet wird: Code:
<?php // CSV-Datei in eine HTML-Tabelle auslesen $daten = file("http://www.beispielseitentext.de/meinedatei.csv", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); echo '<table border>'; foreach ($daten as $nr => $data) { $parts = explode(";", $data); echo '<tr>' foreach ($parts as $part) { echo '<td>' . $part . '</td>'; } echo '</tr>' } echo '</table>'; ?> |
Themen-Optionen | |
Ansicht | |
|
|
Ähnliche Themen | ||||
Thema | Autor | Forum | Antworten | Letzter Beitrag |
Markieren von Inhalten verhindern | marius | Javascript & Ajax | 3 | 29.08.2009 16:17 |
<ul><li> Liste - die Punkte bei "hover" farblich ändern? | Steakfred | CSS | 4 | 03.11.2007 08:31 |
Dieses Forum als gelesen markieren | Loïs Bégué | Fragen, Konstruktive Kritik, Lob / Bekanntmachungen | 3 | 06.07.2007 15:49 |
Screenreader: nur bestimmte Passagen vorlesen lassen...? | paul_le | Barrierefreiheit | 0 | 12.02.2006 10:35 |
aktive Links farblich markieren ?! | aaron | CSS | 1 | 19.09.2005 14:02 |