• Jetzt anmelden. Es dauert nur 2 Minuten und ist kostenlos!

Datenbank auslesen in html Datei

Fabiii321

Mitglied
Hallo,
ich habe eine Frage.
Ich möchte aus einer Datenbank Sachen auslesen.
Momentan lese ich das noch über eine php Datei aus.
Hier der Code:

PHP:
 <?php

include "connect.php";
 
$result = mysql_query('SELECT * FROM rechnungen ORDER BY Rechnungsnummer')
                  or die(mysql_error());
 
$num = mysql_num_rows ($result);
echo "Es wurden $num Datensätze gefunden<br>";    
 
echo '<table>
      <tr><th>ID</th>
          <th>Rechnungsnummer</th>
          <th>AZ</th>
          <th>Vorname</th>
          <th>Nachname</th>
          <th>Betrag</th>
          <th>Versanddatum</th>
          <th>Bezahlt</th>
          <th>Dateityp</th>
          <th>Datei</th>
          <th>Kommentar</th>
      </tr>';
     
while($row = mysql_fetch_array($result))
{
    echo '<tr>';
    echo '<td>' . $row['ID'] . '</td>';
    echo '<td>' . $row['Rechnungsnummer'] . '</td>';
    echo '<td>' . $row['AZ'] . '</td>';
    echo '<td>' . $row['Vorname'] . '</td>';
    echo '<td>' . $row['Nachname'] . '</td>';
    echo '<td>' . $row['Betrag'] . '</td>';
    echo '<td>' . $row['Versanddatum'] . '</td>';
    echo '<td>' . $row['Bezahlt'] . '</td>';
    echo '<td>' . $row['Dateityp'] . '</td>';
    echo '<td>' . $row['Datei'] . '</td>';
    echo '<td>' . $row['Kommentar'] . '</td>';
}      
echo   ('</table>');
?>

Es funktioniert auch alles nur will ich dass Diese Tabellen Ausgabe in einer html Datei ausgegeben werden soll.
Hier ein Bild zum genaueren Verständnis.

Hier das Bild wie es momentan ausgegeben wird:
momentane Ausgabe.jpg

Hier soll es ausgegeben werden (Das ist eine html Datei):

Ausgabe.jpg

Wie macht man sowas ?

Vielen Dank für eure Bemühungen !!!
Gruß
Fabian
 
Also für den Anfang indem du die HTML-Datei mittels include("dateiname.html"); einbindest in die PHP-Datei. Danach musst du nur in deinen DIV diesen Code reinschreiben

HTML:
<div id="ausgabe">
<?php
$num = mysql_num_rows ($result);
echo "Es wurden $num Datensätze gefunden<br>";    
 
echo '<table>
      <tr><th>ID</th>
          <th>Rechnungsnummer</th>
          <th>AZ</th>
          <th>Vorname</th>
          <th>Nachname</th>
          <th>Betrag</th>
          <th>Versanddatum</th>
          <th>Bezahlt</th>
          <th>Dateityp</th>
          <th>Datei</th>
          <th>Kommentar</th>
      </tr>';
     
while($row = mysql_fetch_array($result))
{
    echo '<tr>';
    echo '<td>' . $row['ID'] . '</td>';
    echo '<td>' . $row['Rechnungsnummer'] . '</td>';
    echo '<td>' . $row['AZ'] . '</td>';
    echo '<td>' . $row['Vorname'] . '</td>';
    echo '<td>' . $row['Nachname'] . '</td>';
    echo '<td>' . $row['Betrag'] . '</td>';
    echo '<td>' . $row['Versanddatum'] . '</td>';
    echo '<td>' . $row['Bezahlt'] . '</td>';
    echo '<td>' . $row['Dateityp'] . '</td>';
    echo '<td>' . $row['Datei'] . '</td>';
    echo '<td>' . $row['Kommentar'] . '</td>';
}      
echo   ('</table>');
?>
</div>

Später gibts dann noch bessere Lösungen wie z.B. Smarty um PHP-Variablen in HTML auszugeben. :)
 
Zurück
Oben