购买记录如何显示收货地址和收货人姓名呀。请帮忙看看

2016-07-07 15:01 来源:www.chinab4c.com 作者:ecshop专家

/* 商品购买记录 */
$sql = 'SELECT u.user_name, og.goods_sn,og.goods_number, oi.add_time, IF(oi.order_status IN (2, 3, 4), 0, 1) AS order_status ' .
'FROM ' . $GLOBALS['ecs']->table('order_info') . ' AS oi LEFT JOIN ' . $GLOBALS['ecs']->table('users') . ' AS u ON oi.user_id = u.user_id, ' . $GLOBALS['ecs']->table('order_goods') . ' AS og ' .
'WHERE oi.order_id = og.order_id AND og.goods_id = ' . $arr['id'] . ' ORDER BY oi.add_time DESC LIMIT 5';
$bought_notes = $GLOBALS['db']->getAll($sql);

foreach ($bought_notes as $key => $val)
{
$bought_notes[$key]['add_time'] = local_date("Y-m-d G:i:s", $val['add_time']);
}

$sql = 'SELECT count(*) ' .
'FROM ' . $GLOBALS['ecs']->table('order_info') . ' AS oi LEFT JOIN ' . $GLOBALS['ecs']->table('users') . ' AS u ON oi.user_id = u.user_id, ' . $GLOBALS['ecs']->table('order_goods') . ' AS og ' .
'WHERE oi.order_id = og.order_id AND og.goods_id = ' . $arr['id'];
$count = $GLOBALS['db']->getOne($sql);

回答:


order_info表中有收货人,收货地址~你查询的时候~把他查询出来就行了。
$sql = 'SELECT u.user_name, og.goods_sn,og.goods_number, oi.add_time, IF(oi.order_status IN (2, 3, 4), 0, 1) AS order_status,oi.c**ignee,oi.address ' .
'FROM ' . $GLOBALS['ecs']->table('order_info') . ' AS oi LEFT JOIN ' . $GLOBALS['ecs']->table('users') . ' AS u ON oi.user_id = u.user_id, ' . $GLOBALS['ecs']->table('order_goods') . ' AS og ' .
'WHERE oi.order_id = og.order_id AND og.goods_id = ' . $arr['id'] . ' ORDER BY oi.add_time DESC LIMIT 5';
$bought_notes = $GLOBALS['db']->getAll($sql);

到时认真看看....