2013-03-08 62 views
-1

HI每一個這只是我的第二篇文章,但我真的堅持,並會感謝任何幫助,在此先感謝。我正在從zencart將數據從數據庫導出到2個csv文件,文件一個工作正常,但是當我運行文件2時,我遇到了EOF循環的問題,出於某種原因,它顯示了最後一個產品,數千次以下, dosent結束循環,EOF Loop PHP輸出文件

ST,206,1,WIPAC 8" 4x4 100w Off-Road Driving Lamp Set Inc Grilles,0.0000,0 
ST,387,0,Wolf Bench Grinder - WBG200/MD200F - Home - Tools - DIY,0.0000,0 
ST,360,0,Wolfcraft TS 800 Adjustable Trolley - Home - Garden,0.0000,0 
ST,116,0,WWE Ruthless Aggression 6 Pack - Wrestling Game - RARE - Retro,0.0000,0 
ST,419,0,Zinc Ion XY Black Folding Scooter - Outdoors - Toy,0.0000,0 
ST,220,0,Zoobles Mama & Zoobling Trinka and Tito & Tonia #306 Play Set,0.0000,0 
ST,220,0,Zoobles Mama & Zoobling Trinka and Tito & Tonia #306 Play Set,0.0000,0 
ST,220,0,Zoobles Mama & Zoobling Trinka and Tito & Tonia #306 Play Set,0.0000,0 
ST,220,0,Zoobles Mama & Zoobling Trinka and Tito & Tonia #306 Play Set,0.0000,0 
ST,220,0,Zoobles Mama & Zoobling Trinka and Tito & Tonia #306 Play Set,0.0000,0 
ST,220,0,Zoobles Mama & Zoobling Trinka and Tito & Tonia #306 Play Set,0.0000,0 
ST,220,0,Zoobles Mama & Zoobling Trinka and Tito & Tonia #306 Play Set,0.0000,0 
ST,220,0,Zoobles Mama & Zoobling Trinka and Tito & Tonia #306 Play Set,0.0000,0 
ST,220,0,Zoobles Mama & Zoobling Trinka and Tito & Tonia #306 Play Set,0.0000,0 
ST,220,0,Zoobles Mama & Zoobling Trinka and Tito & Tonia #306 Play Set,0.0000,0 
ST,220,0,Zoobles Mama & Zoobling Trinka and Tito & Tonia #306 Play Set,0.0000,0 

當前的代碼我使用低於(從後感謝喬恩1個衛生組織讓我這麼遠:)

$products_cost = 
"select p.products_id, pd.products_name, p.products_quantity, ". 
    "p.products_cost, (p.products_quantity*p.products_cost) AS products_total_cost, ". 
    "p.products_type ". 
"from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd ". 
"where p.products_id = pd.products_id and pd.language_id='" . $_SESSION['languages_id'] . "' ". 
"order by (p.products_cost) DESC, p.products_cost desc, pd.products_name"; 



$products_stock = $db->Execute($products_cost); 



//Start Of Output for Stock File  

while(!$products_stock->EOF) { 
$output = array();  
$output["tx_type"]='ST';   
$output["Stock_Code"]= $products_stock->fields['products_id']; 
$output["Qty"]= $products_stock->fields['products_quantity']; 
$output["Description"]= $products_stock->fields['products_name']; 
$output["CostPriceEx"]= $products_stock->fields['products_cost']; 
$output["TotalCostEx"]= $products_stock->fields['products_cost'] * $products_stock->fields['products_quantity']; 

zen_sages_fwrite($output); 
$products_stock->MoveNext(); 
} 
$stimer = microtime_float(); 

我真的不歡迎任何建議或指導任何可以給

非常感謝

羅素

回答

1

錯字?

while(!$products_sock->EOF) { 
        ^---missing a T? 
+0

對不起,這是一個複製過去的錯誤,它是while(!$ products_stock-> EOF){ – 2013-03-08 21:21:30

+0

任何想法爲什麼? – 2013-03-08 21:25:01

+0

不知道。還沒有弄清楚你正在使用的db抽象庫是什麼或者它是如何工作的。 – 2013-03-08 21:28:24