27. Februar 200422 j Hi, ich habe eine ganz einfache Produkt-Datenbank mit Bildupload Funktion geschrieben. Ich möchte nun eine Spalte "Bild" hinzufügen, welche für jede Zeile prüft ob in /bilder/upload ein Bild mit der ID der jeweiligen Zeile drin ist ([id].jpg und wenn ja eine Grafik dafür anzeigt. Denn beim Editieren bekommt das hochgeladene Bild als Dateinamen die ID der Zeile. Alles klar? Wäre cool, wenn ihr mir da weiterhelfen könntet. Hier der Code ... //Anzahl der Datensätze $num_rows = mysql_num_rows($result); //Tabelle öffnen und Überschriften anzeigen echo "<table width=800 border=1 align=center > <tr> <th><a href=\"?action=sortprodukt\">Produkt</a></th> <th><a href=\"?action=sortform\">Form</a></th> <th><a href=\"?action=sorttyp\">Typ</a></th> <th><a href=\"?action=sortds\">Druckstufe</a></th> <th><a href=\"?action=sortda\">Druckausgleich</a></th> <th><a href=\"?action=sortsa\">Spindelabdichtung</a></th> <th><a href=\"?action=sortsm\">Sondermerkmal</a></th> <th><a href=\"?action=sorttext\">Beschreibung</a></th> <th> </th> <th> </th> </tr>"; //Schleife zum Auslesen der Daten, bis der Wert num_rows erreicht ist For ($i = 1; $i <= $num_rows; $i++) //Beginnen der Aktionen der For-Schleife { $row=mysql_fetch_array($result); //Ausgeben der Daten echo "<tr><td>"; echo $row["produkt"]; echo "</td><td>"; echo $row["form"]; echo "</td><td>"; echo $row["typ"]; echo "</td><td>"; echo $row["ds"]; echo "</td><td>"; echo $row["da"]; echo "</td><td>"; echo $row["sa"]; echo "</td><td>"; echo $row["sm"]; echo "</td><td>"; echo $row["text"]; echo "</td>"; //Link für Editieren (edit) echo "<td><a href=\"?id="; echo $row["id"]; echo "&action=edit"; echo "\">Editieren</a>"; echo "</td>"; //Link für Löschen (clear) echo "<td><a href=\"?id="; echo $row["id"]; echo "&action=clear"; echo "\">Löschen</a>"; echo "</td></tr>"; //For-Schleife beenden } //Tabelle schließen echo "</table>";[/PHP] MfG ALL:bimei
27. Februar 200422 j // Bild $img = "/upload/bilder/". $row["id"] .".jpg"; echo "<td>"; if ( file_exists( $img)) { echo "<img src=\"". $img ."\">"; } echo "</td>"; [/PHP]
Archiv
Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.