有段代码不是很明白,请高手指点一下!谢谢!

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

/* 取得用户等级和折扣 */
if ($row['user_rank'] == 0)
{
// 非特殊等级,根据等级积分计算用户等级(注意:不包括特殊等级)
$sql = 'SELECT rank_id, discount FROM ' . $GLOBALS['ecs']->table('user_rank') . " WHERE special_rank = '0' AND min_points <= " . intval($row['rank_points']) . ' AND max_points > ' . intval($row['rank_points']);
if ($row = $GLOBALS['db']->getRow($sql))
{
$_SESSION['user_rank'] = $row['rank_id'];
$_SESSION['discount']= $row['discount'] / 100.00;
}
else
{
$_SESSION['user_rank'] = 0;
$_SESSION['discount']= 1;
}
}
else
{
// 特殊等级
$sql = 'SELECT rank_id, discount FROM ' . $GLOBALS['ecs']->table('user_rank') . " WHERE rank_id = '$row[user_rank]'";
if ($row = $GLOBALS['db']->getRow($sql))
{
$_SESSION['user_rank'] = $row['rank_id'];
$_SESSION['discount']= $row['discount'] / 100.00;
}
else
{
$_SESSION['user_rank'] = 0;
$_SESSION['discount']= 1;
}
}

请问$row['user_rank'] 和$_SESSION['user_rank'] 有什么区别呀?谢谢!