[SOLVED PHP Help needed for reading txt file-output as tab

Post non-phpwcms related topics here - but I don't want to see "hey check this or that other cms". Post if you have a point or worthwhile comment, don't post just to increase you post count!
Post Reply
User avatar
oeconom
Posts: 337
Joined: Fri 13. May 2005, 09:33
Location: Stuttgart
Contact:

[SOLVED PHP Help needed for reading txt file-output as tab

Post by oeconom »

Hi you PHP-Masters out there :) ,

as I'm really at the beginning of my php experiences I need your help.
I assume, it will we a silly question and an easy task for you.




What I have:
A txt file with data in the following format:

Code: Select all

231|"Hyosung"|"GT 125"|"NEU"|"15"||"0"|"schwarz"|"NEUFAHRZEUG"|2990
262|"Hyosung"|"GT 125 R"|"NEU"|"15"||"0"|"rot"|"NEUFAHRZEUG"|3990
...


What I want:
Giving out a table with the values in between the " " and a link to a pictue (which has the same name as the first figure in each row plus the file ending .jpg



What I already did and/or found (to be reworked if needed :Wink: ):

Code: Select all

<table border=1>
 <tr>
  <th>Bild</th>
  <th>Marke</th>
  <th>Type</th>
  <th>BJ</th>
  <th>PS</th>
  <th>TÜV</th>
  <th>km</th>
  <th>Farbe</th>
  <th>Zubehör/Bemerkungen</th>
  <th>Preis</th>
 </tr>

<?php
 $datei = "gebrauchte.TXT"; // Name der Datei
 $array = file($datei); // Datei in ein Array einlesen

 for ($i = 0; $i < count($array); $i++) {
  $array[$i] = explode("|" , $array[$i]);
//  echo "<tr><th>" . ($i+1) . "</th>"; // Zeilennummer - brauchen wir nicht
   for ($a = 0; $a < 10; $a++) { // 10 Tabellenspalten
    if ($a == 0) {
     echo "<td><a href=\"" . $array[$i][$a] . "\" target=\"_blank\">" . $array[$i][$a] . "</a></td> \n";
    }
    else {
     echo "<td>" . $array[$i][$a] . "</td> \n";
    }
   }
  echo "</tr> \n";
 }
?>
</table>


What I still need:
-I managed to have the first value being a link, but I still need it to be added the ".jpg", so that the picture is linked and I want the link not to be text, but an icon/picture.
-I'd like to have the quotation marks removen (as the txt file is output of another system, I can't change thant format...)
-I'd like to have the last value ("Preis") bein formatted as currency --> xx.xxx,xx
-Finally, for the optic, I want the table to be online a fine, light-grey dotted grid



I'm looking forward to your answers and help,
thanks in advance for your advice,

FELIX
...alles wird gut!
still alive...
Experimenting with phpwcms and hoping to have time one day to get a site live... :wink:
One Site finished! :P
Post Reply