Hallo alle zusammen, ich habe eine frage....
Ich möchte einige Daten aus Mysql auslesen und in CSV datei schreiben,
hab alles gemacht es schreibt alles perfekt, aber alles in eine Zeile, wo kann die Feller sein, könnt ihr mir herlfen ?
Hier ist die Code:
[code]<?php
require_once('includes/configure.php');
require('includes/application_top.php');
$file="data.csv";
$save=fopen($file,"w");
$hostname_oscommerce = DB_SERVER;
$database_oscommerce = DB_DATABASE;
$username_oscommerce = DB_SERVER_USERNAME;
$password_oscommerce = DB_SERVER_PASSWORD;
$cat =(defined('DIR_WS_HTTP_CATALOG'))?DIR_WS_HTTP_CATA LOG
IR_WS_CATALOG;
$limit="";
if($GLOBALS["count"]>0)
{
$limit=" limit ".(int)$GLOBALS["begin"].",".(int)$GLOBALS["count"];
}
if($GLOBALS["timelimit"]>0) set_time_limit($GLOBALS["timelimit"]);
$sql_query = "select products.products_status,
manufacturers.manufacturers_name,
products.products_id,
products.products_model,
products.verfuegbarkeit,
products.EAN,
products.DAN_Ingram,
products.hersteller_AN,
products.products_image,
products.products_price,
products.products_tax_class_id,
products_description.products_name,
products_description.products_description
from products, products_description,
manufacturers
where products.products_id=products_description.products _id and
manufacturers.manufacturers_id = products.manufacturers_id and
products_description.language_id=2 and
products.products_status > 0 $limit";
$con = mysql_pconnect( $hostname_oscommerce,
$username_oscommerce,
$password_oscommerce) or die("Unable to connect to SQL server");
mysql_select_db($database_oscommerce,$con) or die("Unable to select database.");
$sql_result = mysql_query($sql_query);
while($row = mysql_fetch_array($sql_result))
{
if ($sonderpreis=tep_get_products_special_price($row['products_id']))
{
$preis=$sonderpreis;
$preis_vorher=$row["products_price"];
}
else
{
$preis=$row["products_price"];
$preis_vorher=0;
}
$steuer =(100+tep_get_tax_rate($row['products_tax_class_id']))/100;
$preis =number_format($preis*$steuer,2,".","");
$preis_vorher =number_format($preis_vorher*$steuer,2,".","");
$bezeichnung =escaper($row["products_name"]);
$manufacturer =escaper($row["manufacturers_name"]);
$ean =escaper($row["EAN"]);
$hersteller_an =escaper($row["hersteller_AN"]);
$artikel_nr = $row["products_model"];
$dan_ingram =$row["DAN_Ingram"];
$url =HTTP_SERVER.$cat."product_info.php?products_id=". $row["products_id"];
$verfuegbar =$row["verfuegbarkeit"];
$artikel_id =$row["products_id"];
if(trim($row["products_image"])!="")
if($row["products_id"]>0) // Nur Artikel mit Kategorien exportieren
$post_2 =$manufacturer . ";" . $bezeichnung . ";" . $preis . ";" . $verfuegbar . ";" . $EAN . ";" . $hersteller_AN . ";" . $url . ";" . $artikel_id . ";" . $dan_ingram;
fputs($save,"$post_2");
}
function HoleKategorie($produkt_id)
{
global $katcache;
$rw="";
$kat_id=(int)GetSqlValue("select categories_id as value from products_to_categories where products_id=$produkt_id");
if($kat_id>0)
{
if($katcache[$kat_id]!="")
{
return $katcache[$kat_id];
}
$id=$kat_id;
while($id)
{
$bez=GetSqlValue("select categories_name as value from categories_description where language_id=2 and categories_id=$id");
$id=(int)GetSqlValue("select parent_id as value from categories where categories_id=$id");
if($bez!="<null>")
{
if($rw!="")
$rw=$bez."/".$rw;
else
$rw=$bez;
}
}
$katcache[$kat_id]=$rw;
}
return $rw;
}
function escaper($text)
{
$description=$text;
$description = strip_tags( $description ); //HTML entfernen
$description=str_replace('|',' ',$description); // | entfernen
$description = ereg_replace ("\n", " ", $description); //Zeilenumbr
Ich möchte einige Daten aus Mysql auslesen und in CSV datei schreiben,
hab alles gemacht es schreibt alles perfekt, aber alles in eine Zeile, wo kann die Feller sein, könnt ihr mir herlfen ?
Hier ist die Code:
[code]<?php
require_once('includes/configure.php');
require('includes/application_top.php');
$file="data.csv";
$save=fopen($file,"w");
$hostname_oscommerce = DB_SERVER;
$database_oscommerce = DB_DATABASE;
$username_oscommerce = DB_SERVER_USERNAME;
$password_oscommerce = DB_SERVER_PASSWORD;
$cat =(defined('DIR_WS_HTTP_CATALOG'))?DIR_WS_HTTP_CATA LOG
$limit="";
if($GLOBALS["count"]>0)
{
$limit=" limit ".(int)$GLOBALS["begin"].",".(int)$GLOBALS["count"];
}
if($GLOBALS["timelimit"]>0) set_time_limit($GLOBALS["timelimit"]);
$sql_query = "select products.products_status,
manufacturers.manufacturers_name,
products.products_id,
products.products_model,
products.verfuegbarkeit,
products.EAN,
products.DAN_Ingram,
products.hersteller_AN,
products.products_image,
products.products_price,
products.products_tax_class_id,
products_description.products_name,
products_description.products_description
from products, products_description,
manufacturers
where products.products_id=products_description.products _id and
manufacturers.manufacturers_id = products.manufacturers_id and
products_description.language_id=2 and
products.products_status > 0 $limit";
$con = mysql_pconnect( $hostname_oscommerce,
$username_oscommerce,
$password_oscommerce) or die("Unable to connect to SQL server");
mysql_select_db($database_oscommerce,$con) or die("Unable to select database.");
$sql_result = mysql_query($sql_query);
while($row = mysql_fetch_array($sql_result))
{
if ($sonderpreis=tep_get_products_special_price($row['products_id']))
{
$preis=$sonderpreis;
$preis_vorher=$row["products_price"];
}
else
{
$preis=$row["products_price"];
$preis_vorher=0;
}
$steuer =(100+tep_get_tax_rate($row['products_tax_class_id']))/100;
$preis =number_format($preis*$steuer,2,".","");
$preis_vorher =number_format($preis_vorher*$steuer,2,".","");
$bezeichnung =escaper($row["products_name"]);
$manufacturer =escaper($row["manufacturers_name"]);
$ean =escaper($row["EAN"]);
$hersteller_an =escaper($row["hersteller_AN"]);
$artikel_nr = $row["products_model"];
$dan_ingram =$row["DAN_Ingram"];
$url =HTTP_SERVER.$cat."product_info.php?products_id=". $row["products_id"];
$verfuegbar =$row["verfuegbarkeit"];
$artikel_id =$row["products_id"];
if(trim($row["products_image"])!="")
if($row["products_id"]>0) // Nur Artikel mit Kategorien exportieren
$post_2 =$manufacturer . ";" . $bezeichnung . ";" . $preis . ";" . $verfuegbar . ";" . $EAN . ";" . $hersteller_AN . ";" . $url . ";" . $artikel_id . ";" . $dan_ingram;
fputs($save,"$post_2");
}
function HoleKategorie($produkt_id)
{
global $katcache;
$rw="";
$kat_id=(int)GetSqlValue("select categories_id as value from products_to_categories where products_id=$produkt_id");
if($kat_id>0)
{
if($katcache[$kat_id]!="")
{
return $katcache[$kat_id];
}
$id=$kat_id;
while($id)
{
$bez=GetSqlValue("select categories_name as value from categories_description where language_id=2 and categories_id=$id");
$id=(int)GetSqlValue("select parent_id as value from categories where categories_id=$id");
if($bez!="<null>")
{
if($rw!="")
$rw=$bez."/".$rw;
else
$rw=$bez;
}
}
$katcache[$kat_id]=$rw;
}
return $rw;
}
function escaper($text)
{
$description=$text;
$description = strip_tags( $description ); //HTML entfernen
$description=str_replace('|',' ',$description); // | entfernen
$description = ereg_replace ("\n", " ", $description); //Zeilenumbr

Kommentar