", ">", $s); //$s = htmlentities($s); //$s = str_replace("&", "&", $s); return $s; } $t0 = "\t"; $t1 = "\t\t"; $t2 = "\t\t\t"; $t3 = "\t\t\t\t"; //Make a connection to the db include("connect_mssql_net.php"); //Print xml start tag $s = "\n"; //and the root element $s .= "\n"; //Quering the db for the data $sqlQuery = "SELECT no, name, brnd, ". "cast(udsr AS TEXT) as udsr, dateupdate, qty, unit, ean, eu, bw, nw, dw, ". "ht, wd, ln, ie, oe, pvc, ". "cast(ingr AS TEXT) as ingr, en, pro, fat, car ". "FROM NordlieData ". "ORDER BY no"; $result = mssql_query($sqlQuery) or die("SQL forespørgslen indeholder følgende fejl: \n"); while($row = mssql_fetch_array($result)) { //Item $no = replace($row["no"]); $name = replace($row["name"]); if(strlen($name) > 35) $name = substr($name, 0, 35); $brnd = replace($row["brnd"]); $udsr = replace($row["udsr"]); $rev = date("dmy", strtotime($row["dateupdate"])); //PDT $img = "http://www.nordliefood.dk/images/".$no.".jpg"; //QTI $qty = replace($row["qty"]); $qty = ($qty == '-1') ? '' : $qty; $unit = replace($row["unit"]); $tu = "1"; //replace($row["tu"]); //$tu = ($tu == '-1') ? '' : $tu; $su = "1"; //replace($row["su"]); //$su = ($su == '-1') ? '' : $su; $ean = replace($row["ean"]); $ean = ($ean == '-1') ? '' : $ean; $eu = replace($row["eu"]); $eu = ($eu == '-1') ? '' : $eu; //MEA $bw = replace($row["bw"]); $bw = ($bw == '-1') ? '' : $bw; $nw = replace($row["nw"]); $nw = ($nw == '-1') ? '' : $nw; $dw = replace($row["dw"]); $dw = ($dw == '-1') ? '' : $dw; $ht = replace($row["ht"]); $ht = ($ht == '-1') ? '' : 100*$ht; $wd = replace($row["wd"]); $wd = ($wd == '-1') ? '' : 100*$wd; $ln = replace($row["ln"]); $ln = ($ln == '-1') ? '' : 100*$ln; //EMB $ie = replace($row["ie"]); $oe = replace($row["oe"]); $pvc = replace($row["pvc"]); $pvc = ($pvc == '-1') ? '' : $pvc; //ORG $cty = ""; //replace($row["cty"]); //INGR $ingr = replace($row["ingr"]); //PROX $en = replace($row["en"]); $en = ($en == '-1') ? '' : $en; $pro = replace($row["pro"]); $pro = ($pro == '-1') ? '' : $pro; $fat = replace($row["fat"]); $fat = ($fat == '-1') ? '' : $fat; $car = replace($row["car"]); $car = ($car == '-1') ? '' : $car; //Item $s .= $t0.''; $s .= "\n"; //PDT $s .= $t1.''; // IMGH="" $s .= "\n"; //QTI $s .= $t2.''; $s .= "\n"; //MEA $s .= $t3."\n"; //HAN //$s .= $t3."\n"; //EMB $s .= $t3."\n"; //END QTI $s .= $t2."\n"; //ORG //$s .= $t2."\n"; /*CTY=\"".$cty."\"*/ //INGR $s .= $t2."\n"; $s .= $t3.$ingr."\n"; $s .= $t2."\n"; //USR //$s .= $t2."\n"; //END PDT $s .= $t1."\n"; //NUT $s .= $t1."\n"; //PROX $s .= $t2."\n"; //MIN //$s .= $t2."\n"; //VIT //$s .= $t2."\n"; //LIP //$s .= $t2."\n"; //SFA //$s .= $t3."\n"; //MUFA //$s .= $t3."\n"; //PUFA //$s .= $t3."\n"; //TFS //$s .= $t3."\n"; //END lip //$s .= $t2."\n"; //ACID //$s .= $t2."\n"; //BAK //$s .= $t2."\n"; //END NUT $s .= $t1."\n"; //END ITEM $s .= $t0."\n\n"; } $s .= "\n"; header("Content-type: application/octet-stream"); header("Content-disposition: attachment; filename=produktdata.xml"); header('Cache-Control: private'); header('Pragma: no-cache'); //Read the file to download //readfile($filePath); print($s); ?>