Uli: Excel Tabelle erstellen

Beitrag lesen

Wie kann ich eine Excel Tabelle aus einer MySQL Datenbank Tabelle erstellen und auf den Server ablegen ?

<?PHP
/*************************************************************************************************************
*    MySQL2Excel
*    version: v0.0.1 (NOT TO BE CONTINUED...)
*    author: e-voc [Uwe Pries]
*    mailto: webmaster@judas-price.de
*    date: 2000-12-31
*************************************************************************************************************
*    version: v0.0.2
*    mailto: mmuench@voltra.net
*    date: 2001-03-31
*************************************************************************************************************
*    version: v0.0.3
*    mailto: sascha@kulawik.de
*    date: 2001-06-25
*************************************************************************************************************/

if($host && $user && $password && $database && $table) {

$query_text = "SELECT * FROM " . $table;

Header("Content-Type: application/vnd.ms-excel");

$db_link = mysql_connect($host, $user, $password);
    mysql_select_db($database, $db_link);

$result = mysql_query($query_text, $db_link);
    $fieldcounts = mysql_num_fields($result);
    for($i = 0; $i < $fieldcounts; $i++) {
        $fieldtype = mysql_fetch_field($result, $i);
        if ($i < ($fieldcounts-1)) echo "$fieldtype->name [$fieldtype->type]\t";
            else  echo "$fieldtype->name [$fieldtype->type]\n";
    }
    $myrow = mysql_fetch_array($result);
    do {
        for($i = 0; $i < $fieldcounts; $i++) {
            $fieldname = mysql_field_name($result, $i);
            if ($i < ($fieldcounts-1)) echo $myrow[$fieldname] . "\t";
                else echo $myrow[$fieldname] . "\n";
        }
    } while ($myrow = mysql_fetch_array($result));
} else {
?>
<form action="mysql2excel.php" method="post" target="_blank">
<table>
<tr>
    <td>DB Host</td>
    <td><input type="text" name="host" value="<?php echo $host; ?>"></td>
</tr>
<tr>
    <td>Benutzer</td>
    <td><input type="text" name="user" value="<?php echo $user; ?>"></td>
</tr>
<tr>
    <td>Passwort</td>
    <td><input type="password" name="password" value="<?php echo $password; ?>"></td>
</tr>
<tr>
    <td>Datenbank</td>
    <td><input type="text" name="database" value="<?php echo $database; ?>"></td>
</tr>
<tr>
    <td>Tabelle</td>
    <td><input type="text" name="table" value="<?php echo $table; ?>"></td>
</tr>
</table>
<br>
<input type="submit" name="submit" value="Daten nach MS Excel laden">
</form>
<?php
}
?>

HAb ich im Netz gefunden...
Gruß Uli