Menu

DBF Datei mit Artikel einlesen

Help 2.02
Alex
2004-01-12
2004-01-15
  • Alex

    Alex - 2004-01-12

    Hi!

    Ich habe ein DBF Datei und mchte diese gerne einlesen, da in der Datei ca. 200 Artikel stehen! Gibt es ne Mglichkeit diese einzulesen?

    Danke

    Gru

    Alex

     
    • Andreas Kansok

      Andreas Kansok - 2004-01-13

      Ein ganz einfaches Script, da Dir zumindest den Inhalt der Datei anzeigt. Statt den Kram anzuzeigen, wrde ich eine CSV-Datei, wie phPay sie erwartet, erzeugen lassen und erst diese CSV-Datei dann importieren.
      http://www.php.net/manual/de/ref.dbase.php

      <?php
      if ($fp=fopen("./import/dbfile.dbf") {
        $nr = dbase_numrecords($fp);
        echo "<table>";
        $headdata = dbase_get_record_with_names ( $fp, 1);
        foreach ($headdata as $hk => $hv) { $headline[]=$hk; }
        echo "<tr class=\&quot;thead\&quot;><td>".implode("</td><td>", $headline)."</td></tr>\n";
        for ($i=1; $i <= $nr; $i++)
        {
          $data = dbase_get_record($fp,$i);
          echo "<tr ".clr_cl()."><td>".implode("</td><td>", $data)."</td></tr>\n";
        }
        dbase_close($fp);
        echo "</table>\n";
        exit;
      }
      ?>

       
      • Andreas Kansok

        Andreas Kansok - 2004-01-13

        Kleiner Nachtrag: Die Funktion clr_cl() macht nix weiter als abwechseln die CSS-Klassen white und lightgrey zuzuweisen:
        function clr_cl()
        {
          static $j=0;
          $j++;
          if ($j % 2 == 0) return "class=lightgrey";
          else return "class=white";
        }

        <style type="text/css">
        *.thead { font-family:sans-serif; font-size:11px; color:#000000; font-weight:bold; font-align:left; background-color: #C0C0C0;}
        *.lightgrey {background-color: #EEEEEE;}
        *.white {background-color: #FFFFFF;}
        </style>

         
    • Alex

      Alex - 2004-01-15

      Vielen Dank!

      Werde es am Wochenende gleich mal ausprobieren!

      Gru

      Alex

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.