我是论坛的新手,但希望有人可以帮我解决困难..
我的代码在下面,我正在从 zen cart 数据库导出到 csv 文件
$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
$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);
$stimer = microtime_float();
运行代码时,我得到如下输出,但不是显示数据库中的每个产品,而是显示相同的产品??
ST,1149,10,350gsm A6 Glossy Postcards,290.0000,2900
ST,1149,10,350gsm A6 Glossy Postcards,290.0000,2900
ST,1149,10,350gsm A6 Glossy Postcards,290.0000,2900
ST,1149,10,350gsm A6 Glossy Postcards,290.0000,2900
ST,1149,10,350gsm A6 Glossy Postcards,290.0000,2900
ST,1149,10,350gsm A6 Glossy Postcards,290.0000,2900
ST,1149,10,350gsm A6 Glossy Postcards,290.0000,2900
ST,1149,10,350gsm A6 Glossy Postcards,290.0000,2900
ST,1149,10,350gsm A6 Glossy Postcards,290.0000,2900
ST,1149,10,350gsm A6 Glossy Postcards,290.0000,2900
ST,1149,10,350gsm A6 Glossy Postcards,290.0000,2900
我试过添加$products_stock->MoveNext();
但是打缝有什么影响,
提前谢谢大家
罗素
我的代码现在看起来像
//股票文件的输出开始
$output = array(); while (!$products_stock->EOF) {
$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'];
$products_stock->MoveNext;
}
zen_sages_fwrite($output);
$stimer = microtime_float();