PDA

Shop Support News Archive - Shopbetreiber News -> Forum : xt eCommerce Templates Module SEO Support: eCommerce GPL Shopsoftware : Csv Export Aus Admin


bluemoon
07.04.2006, 23:44
Ich möchte aus der Bestellübersnicht, bzw. der Einzelbestellung die Kundenadresse als CSV exportieren ;

hat da wer ne Idee, wie sich das realisieren lässt ?

Ich habe jetzt einen Export Button eingefügt und eine entsprehcende Datei zum exportieren der Daten

wenn ich aber die ID der Bestellung an das Export Script übergebe, werden alle Daten exportiert, nicht nur die der aktuellen Bestellung

hier das export Script


<?php

$DatabaseHost = "localhost";
$DatabaseUser = "";
$DatabasePassword = "";
$Database = "";
$Table = "";

header('Content-Type: text/x-csv');
header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Content-Dispoistion: attachment; filename=orders.csv');
header('Pragma: no-cache');

$DatabasePointer = mysql_connect($DatabaseHost, $DatabaseUser, $DatabasePassword);
mysql_select_db($Database, $DatabasePointer);

$ResultPointer = mysql_query("SELECT orders_id, customers_id, customers_cid, customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_country, customers_telephone, customers_email_address, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_country, billing_name, billing_company, billing_street_address, billing_suburb,**billing_city,**billing_postcode, billing_country, payment_method, comments, date_purchased, orders_status FROM $Table");

for($i=0, $Export=""; $i<mysql_num_rows($ResultPointer); $i++)
{
$Daten = mysql_fetch_object($ResultPointer);


$Spalte[] = str_replace("\"", "\"\"", $Daten->orders_id);
$Spalte[] = str_replace("\"", "\"\"", $Daten->customers_cid);
$Spalte[] = str_replace("\"", "\"\"", $Daten->customers_id);
$Spalte[] = str_replace("\"", "\"\"", $Daten->customers_name);
$Spalte[] = str_replace("\"", "\"\"", $Daten->customers_company);
$Spalte[] = str_replace("\"", "\"\"", $Daten->customers_street_address);
$Spalte[] = str_replace("\"", "\"\"", $Daten->customers_suburb);
$Spalte[] = str_replace("\"", "\"\"", $Daten->customers_city);
$Spalte[] = str_replace("\"", "\"\"", $Daten->customers_postcode);
$Spalte[] = str_replace("\"", "\"\"", $Daten->customers_country);
$Spalte[] = str_replace("\"", "\"\"", $Daten->customers_telephone);
$Spalte[] = str_replace("\"", "\"\"", $Daten->customers_email_address);
$Spalte[] = str_replace("\"", "\"\"", $Daten->delivery_name);
$Spalte[] = str_replace("\"", "\"\"", $Daten->delivery_company);
$Spalte[] = str_replace("\"", "\"\"", $Daten->delivery_street_address);
$Spalte[] = str_replace("\"", "\"\"", $Daten->delivery_suburb);
$Spalte[] = str_replace("\"", "\"\"", $Daten->delivery_city);
$Spalte[] = str_replace("\"", "\"\"", $Daten->delivery_postcode);
$Spalte[] = str_replace("\"", "\"\"", $Daten->delivery_country);
$Spalte[] = str_replace("\"", "\"\"", $Daten->billing_name);
$Spalte[] = str_replace("\"", "\"\"", $Daten->billing_company);
$Spalte[] = str_replace("\"", "\"\"", $Daten->billing_street_address);
$Spalte[] = str_replace("\"", "\"\"", $Daten->billing_suburb);
$Spalte[] = str_replace("\"", "\"\"", $Daten->billing_city);
$Spalte[] = str_replace("\"", "\"\"", $Daten->billing_postcode);
$Spalte[] = str_replace("\"", "\"\"", $Daten->billing_country);
$Spalte[] = str_replace("\"", "\"\"", $Daten->payment_method);
$Spalte[] = str_replace("\"", "\"\"", $Daten->payment_method);
$Spalte[] = str_replace("\"", "\"\"", $Daten->date_purchased);
$Spalte[] = str_replace("\"", "\"\"", $Daten->payment_method);
$Spalte[] = str_replace("\"", "\"\"", $Daten->orders_status);



for($j=0; $j<count($Spalte); $j++)
{
$Export .= "\"" . $Spalte[$j] . "\"";
if($j!=count($Spalte)-1)
{
**$Export .= ";";
}
}
$Export .= "\r\n";
$Spalte = "";
}

echo$Export;

?>


übergeben wird die ID

export.php?oID=xx&cID=x

xx steht für die Bestellnummer und x für den Kunden


Wie bringe ich jetzt meine export.php dazu, nur die gewünschte Spalte als CSV auszugeben ?

TechWay
08.04.2006, 15:26
Hallo bluemoon :)

dass ist ganz einfach. und zwar musst du in dem SQL-Statement noch eine WHERE-Kausel hinzufügen, welche dann die gewünschte orders_id beinhaltet.

ich habs mal probiert es zu modifizieren:


<?php

$DatabaseHost = "localhost";
$DatabaseUser = "";
$DatabasePassword = "";
$Database = "";
$Table = "";

header('Content-Type: text/x-csv');
header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Content-Dispoistion: attachment; filename=orders.csv');
header('Pragma: no-cache');

$DatabasePointer = mysql_connect($DatabaseHost, $DatabaseUser, $DatabasePassword);
mysql_select_db($Database, $DatabasePointer);

$ResultPointer = mysql_query("SELECT orders_id, customers_id, customers_cid, customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_country, customers_telephone, customers_email_address, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_country, billing_name, billing_company, billing_street_address, billing_suburb,**billing_city,**billing_postcode, billing_country, payment_method, comments, date_purchased, orders_status FROM $Table WHERE orders_id = '" .**$_GET['oID'] . "'");

for($i=0, $Export=""; $i<mysql_num_rows($ResultPointer); $i++)
{
$Daten = mysql_fetch_object($ResultPointer);
$Spalte[] = str_replace("\"", "\"\"", $Daten->orders_id);
$Spalte[] = str_replace("\"", "\"\"", $Daten->customers_cid);
$Spalte[] = str_replace("\"", "\"\"", $Daten->customers_id);
$Spalte[] = str_replace("\"", "\"\"", $Daten->customers_name);
$Spalte[] = str_replace("\"", "\"\"", $Daten->customers_company);
$Spalte[] = str_replace("\"", "\"\"", $Daten->customers_street_address);
$Spalte[] = str_replace("\"", "\"\"", $Daten->customers_suburb);
$Spalte[] = str_replace("\"", "\"\"", $Daten->customers_city);
$Spalte[] = str_replace("\"", "\"\"", $Daten->customers_postcode);
$Spalte[] = str_replace("\"", "\"\"", $Daten->customers_country);
$Spalte[] = str_replace("\"", "\"\"", $Daten->customers_telephone);
$Spalte[] = str_replace("\"", "\"\"", $Daten->customers_email_address);
$Spalte[] = str_replace("\"", "\"\"", $Daten->delivery_name);
$Spalte[] = str_replace("\"", "\"\"", $Daten->delivery_company);
$Spalte[] = str_replace("\"", "\"\"", $Daten->delivery_street_address);
$Spalte[] = str_replace("\"", "\"\"", $Daten->delivery_suburb);
$Spalte[] = str_replace("\"", "\"\"", $Daten->delivery_city);
$Spalte[] = str_replace("\"", "\"\"", $Daten->delivery_postcode);
$Spalte[] = str_replace("\"", "\"\"", $Daten->delivery_country);
$Spalte[] = str_replace("\"", "\"\"", $Daten->billing_name);
$Spalte[] = str_replace("\"", "\"\"", $Daten->billing_company);
$Spalte[] = str_replace("\"", "\"\"", $Daten->billing_street_address);
$Spalte[] = str_replace("\"", "\"\"", $Daten->billing_suburb);
$Spalte[] = str_replace("\"", "\"\"", $Daten->billing_city);
$Spalte[] = str_replace("\"", "\"\"", $Daten->billing_postcode);
$Spalte[] = str_replace("\"", "\"\"", $Daten->billing_country);
$Spalte[] = str_replace("\"", "\"\"", $Daten->payment_method);
$Spalte[] = str_replace("\"", "\"\"", $Daten->payment_method);
$Spalte[] = str_replace("\"", "\"\"", $Daten->date_purchased);
$Spalte[] = str_replace("\"", "\"\"", $Daten->payment_method);
$Spalte[] = str_replace("\"", "\"\"", $Daten->orders_status);
for($j=0; $j<count($Spalte); $j++)
{
$Export .= "\"" . $Spalte[$j] . "\"";
if($j!=count($Spalte)-1)
{
**$Export .= ";";
}
}
$Export .= "\r\n";
$Spalte = "";
}

echo$Export;

?>


Ich glaube so müsste es funktionieren...

Gruß
Steffen

bluemoon
08.04.2006, 23:42
manchmal sieht man den Wald vor lauter Bäumen nicht !

herzlichen Dank

bluemoon
08.04.2006, 23:56
wie kann ich die Datei jetzt anpassen, dass ich ohne die Datenbank Daten auskomme und die configure.php einbinde.

TechWay
09.04.2006, 15:35
Hi,

ich habs jetzt an xtc angepasst:


<?php
include( 'includes/application_top.php');

header('Content-Type: text/x-csv');
header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Content-Dispoistion: attachment; filename=orders.csv');
header('Pragma: no-cache');

$ResultPointer = xtc_db_query("SELECT
********************************orders_id,
********************************customers_id,
********************************customers_cid,
********************************customers_name,
********************************customers_company,
********************************customers_street_a ddress,
********************************customers_suburb,
********************************customers_city,
********************************customers_postcode ,
********************************customers_country,
********************************customers_telephon e,
********************************customers_email_ad dress,
********************************delivery_name,
********************************delivery_company,
********************************delivery_street_ad dress,
********************************delivery_suburb,
********************************delivery_city,
********************************delivery_postcode,
********************************delivery_country,
********************************billing_name,
********************************billing_company,
********************************billing_street_add ress,
********************************billing_suburb,**
********************************billing_city,**
********************************billing_postcode,
********************************billing_country,
********************************payment_method,
********************************comments,
********************************date_purchased,
********************************orders_status
********************************FROM " . TABLE_ORDERS . " WHERE
********************************orders_id = '" .**$_GET['oID'] . "'");

for($i=0, $Export=""; $i<xtc_db_num_rows($ResultPointer); $i++)
{
****$Daten = xtc_db_fetch_array($ResultPointer);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['orders_id']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['customers_cid']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['customers_id']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['customers_name']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['customers_company']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['customers_street_address']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['customers_suburb']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['customers_city']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['customers_postcode']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['customers_country']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['customers_telephone']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['customers_email_address']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['delivery_name']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['delivery_company']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['delivery_street_address']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['delivery_suburb']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['delivery_city']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['delivery_postcode']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['delivery_country']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['billing_name']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['billing_company']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['billing_street_address']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['billing_suburb']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['billing_city']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['billing_postcode']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['billing_country']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['payment_method']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['payment_method']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['date_purchased']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['payment_method']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['orders_status']);
****
****for($j=0; $j<count($Spalte); $j++)
****{
********$Export .= "\"" . $Spalte[$j] . "\"";
********if($j!=count($Spalte)-1)
**********$Export .= ";";
****}
****
****$Export .= "\r\n";
****$Spalte = "";
}

echo$Export;
?>


ich habs kurz angetestet, es klappt wunderbar... wenn du allerdings diese Datei in Admin Ordner reintust, dann musst du den Pfad zur application_top.php (2. Zeile) anpassen

Gruß
Steffen

bluemoon
09.04.2006, 20:07
Du bist klasse !

Danke

TechWay
09.04.2006, 21:23
Bitte schön :-)

wäre doch was fürn Downloadbereich :-)
jetzt müsste man dort noch angeben können Bestellung ab Nr. X bis Nr. Y

bluemoon
10.04.2006, 00:00
ich habe bisher nur hinbekommen, entweder alles zu exportieren, oder nur die übergebene ID.

Aber stimmt, wäre was für den Downloadbereich

voliere.net
12.09.2006, 22:27
Hallo Jungs,

ich habe versucht eine csv-Ausgabe mittels der o. g. Dateien zu ziehen. Leider erhalte ich bei beiden ausgaben eine Null-Runde. Bei der zweiten Ausgabe von Techway habe ich in der Table admin-access den export hinzugefügt.
Die Datei habe ich in root/admin eingefügt und rufe sie direkt auf.

folgendes habe ich nicht so ganz verstanden:
...den Pfad zur application_top.php (2. Zeile) anpassen....

mr_swell
16.04.2007, 15:35
''>ZITAT(TechWay @ Apr 9 2006, 14:35) 3262
Hi,

ich habs jetzt an xtc angepasst:


<?php
include( 'includes/application_top.php');

header('Content-Type: text/x-csv');
header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Content-Dispoistion: attachment; filename=orders.csv');
header('Pragma: no-cache');

$ResultPointer = xtc_db_query("SELECT
********************************orders_id,
********************************customers_id,
********************************customers_cid,
********************************customers_name,
********************************customers_company,
********************************customers_street_a ddress,
********************************customers_suburb,
********************************customers_city,
********************************customers_postcode ,
********************************customers_country,
********************************customers_telephon e,
********************************customers_email_ad dress,
********************************delivery_name,
********************************delivery_company,
********************************delivery_street_ad dress,
********************************delivery_suburb,
********************************delivery_city,
********************************delivery_postcode,
********************************delivery_country,
********************************billing_name,
********************************billing_company,
********************************billing_street_add ress,
********************************billing_suburb,**
********************************billing_city,**
********************************billing_postcode,
********************************billing_country,
********************************payment_method,
********************************comments,
********************************date_purchased,
********************************orders_status
********************************FROM " . TABLE_ORDERS . " WHERE
********************************orders_id = '" .**$_GET['oID'] . "'");

for($i=0, $Export=""; $i<xtc_db_num_rows($ResultPointer); $i++)
{
****$Daten = xtc_db_fetch_array($ResultPointer);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['orders_id']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['customers_cid']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['customers_id']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['customers_name']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['customers_company']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['customers_street_address']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['customers_suburb']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['customers_city']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['customers_postcode']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['customers_country']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['customers_telephone']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['customers_email_address']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['delivery_name']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['delivery_company']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['delivery_street_address']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['delivery_suburb']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['delivery_city']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['delivery_postcode']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['delivery_country']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['billing_name']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['billing_company']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['billing_street_address']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['billing_suburb']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['billing_city']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['billing_postcode']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['billing_country']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['payment_method']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['payment_method']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['date_purchased']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['payment_method']);
****$Spalte[] = str_replace("\"", "\"\"", $Daten['orders_status']);
****
****for($j=0; $j<count($Spalte); $j++)
****{
********$Export .= "\"" . $Spalte[$j] . "\"";
********if($j!=count($Spalte)-1)
**********$Export .= ";";
****}
****
****$Export .= "\r\n";
****$Spalte = "";
}

echo$Export;
?>


ich habs kurz angetestet, es klappt wunderbar... wenn du allerdings diese Datei in Admin Ordner reintust, dann musst du den Pfad zur application_top.php (2. Zeile) anpassen

Gruß
Steffen
[/b]


Hallo,
ich bin genau auf der Suche nach dieser Funktion, wenn ich das Script aufrufe
wird eine Excel Datei erzeugt, allerdings ohne Inhalt.....
Ich benutze die Version v3.0.4 SP2.1, kann es sein das dort die Abfrage geändert wurde,
hat mir sonst noch jemand einen Tip/Hilfe?
Besten Dank und Gruss an alle
JO

Hallo,
ich bin genau auf der Suche nach dieser Funktion, wenn ich das Script aufrufe
wird eine Excel Datei erzeugt, allerdings ohne Inhalt.....
Ich benutze die Version v3.0.4 SP2.1, kann es sein das dort die Abfrage geändert wurde,
hat mir sonst noch jemand einen Tip/Hilfe?
Besten Dank und Gruss an alle
JO