我已经花了几个小时在这上面,但我无法弄清楚。下面我的 while 循环返回相同的记录(小计:)三次。请参阅下图了解我的表结构。此外,这是在 OsCommerce 安装中,因此“tep_.....”功能是 OsCommerce 的东西。我不相信他们是问题,因为我在这里尝试了其他一些非 OsCommerce 解决方案。
$ot_query = tep_db_query("select * from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int) $order_id . "'");
if (tep_db_num_rows($ot_query)) {
while ($ot = tep_db_fetch_array($ot_query)) {
$order_total_sql = tep_db_query("select * from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int) $order_id . "'");
$order_total_result = tep_db_fetch_array($order_total_sql);
$email_order .= strip_tags($order_total_result['title']) . ' ' . strip_tags($order_total_result['text']) . "\n";
}
}
表结构...
orders_total_id | orders_id | title | text | value | class | sort_order
三个不同的行具有相同的orders_id,但orders_total_id 不同,当然其他数据也不同。
- - 更新 - -
添加
echo "<pre>".print_r($ot, 1)."</pre>\n";
在while ($ot = tep_db_fetch_array($ot_query)) {下产生以下...
Array
(
[orders_total_id] => 4149
[orders_id] => 1280
[title] => Sub-Total:
[text] => $49.99
[value] => 49.9900
[class] => ot_subtotal
[sort_order] => 1
)
Array
(
[orders_total_id] => 4150
[orders_id] => 1280
[title] => Gift Certificates (-) :
[text] => $37.00
[value] => 37.0000
[class] => ot_gv
[sort_order] => 3
)
Array
(
[orders_total_id] => 4151
[orders_id] => 1280
[title] => Total:
[text] => $12.99
[value] => 12.9900
[class] => ot_total
[sort_order] => 12
)