PHP 部分代码不清楚 不明白 求高手解释
$select="selectid,shoppingfromtb_userwherename='".$_SESSION['member']."'";$rst=$admin...
$select = "select id,shopping from tb_user where name ='".$_SESSION['member']."'";
$rst = $admindb->ExecSQL($select,$conn);
if($rst[0]['shopping']==""){
echo "<p>";
echo '购物车中暂时没有商品!';
exit();
}
$commarr = array();
foreach($rst[0] as $value){
$tmpnum = explode('@',$value);
$shopnum = count($tmpnum); //商品类数
$sum = 0;
foreach($tmpnum as $key => $vl){
$s_commo = explode(',',$vl);
$sql2 = "select id,name,m_price,fold,v_price from tb_commo";
$commsql = $sql2." where id = ".$s_commo[0];
$arr = $admindb->ExecSQL($commsql,$conn);
@$arr[0]['num'] = $s_commo[1];
@$arr[0]['total'] = $s_commo[1]*$arr[0]['v_price'];
$sum += $arr[0]['total'];
$commarr[$key] = $arr[0];
}
}
$smarty->assign('shoparr',$shopnum);
$smarty->assign('commarr',$commarr);
$smarty->assign('sum',$sum);
?>
这部分代码求解释
$commarr = array();
foreach($rst[0] as $value){
$tmpnum = explode('@',$value);
$shopnum = count($tmpnum); //商品数量
$sum = 0;
foreach($tmpnum as $key => $vl){ 求解释
$s_commo = explode(',',$vl);求解释
$sql2 = "select id,name,m_price,fold,v_price from tb_commo";
$commsql = $sql2." where id = ".$s_commo[0]; 求解释
$arr = $admindb->ExecSQL($commsql,$conn);
@$arr[0]['num'] = $s_commo[1];//求解释
@$arr[0]['total'] = $s_commo[1]*$arr[0]['v_price'];
$sum += $arr[0]['total']; 求解释
解释是很多 ,但是对我有用 重要 展开
$rst = $admindb->ExecSQL($select,$conn);
if($rst[0]['shopping']==""){
echo "<p>";
echo '购物车中暂时没有商品!';
exit();
}
$commarr = array();
foreach($rst[0] as $value){
$tmpnum = explode('@',$value);
$shopnum = count($tmpnum); //商品类数
$sum = 0;
foreach($tmpnum as $key => $vl){
$s_commo = explode(',',$vl);
$sql2 = "select id,name,m_price,fold,v_price from tb_commo";
$commsql = $sql2." where id = ".$s_commo[0];
$arr = $admindb->ExecSQL($commsql,$conn);
@$arr[0]['num'] = $s_commo[1];
@$arr[0]['total'] = $s_commo[1]*$arr[0]['v_price'];
$sum += $arr[0]['total'];
$commarr[$key] = $arr[0];
}
}
$smarty->assign('shoparr',$shopnum);
$smarty->assign('commarr',$commarr);
$smarty->assign('sum',$sum);
?>
这部分代码求解释
$commarr = array();
foreach($rst[0] as $value){
$tmpnum = explode('@',$value);
$shopnum = count($tmpnum); //商品数量
$sum = 0;
foreach($tmpnum as $key => $vl){ 求解释
$s_commo = explode(',',$vl);求解释
$sql2 = "select id,name,m_price,fold,v_price from tb_commo";
$commsql = $sql2." where id = ".$s_commo[0]; 求解释
$arr = $admindb->ExecSQL($commsql,$conn);
@$arr[0]['num'] = $s_commo[1];//求解释
@$arr[0]['total'] = $s_commo[1]*$arr[0]['v_price'];
$sum += $arr[0]['total']; 求解释
解释是很多 ,但是对我有用 重要 展开
2个回答
展开全部
foreach($tmpnum as $key => $vl) foreach是对数据循环 key与vl分别对应 $tmpnum['key']=>$vl;
$commsql = $sql2." where id = ".$s_commo[0]; 等于
$commsql =“select id,name,m_price,fold,v_price from tb_commo where id = $s_commo[0]“;
@$arr[0]['num'] = $s_commo[1]; 是不要报错
$sum += $arr[0]['total']; 等于 $sum =$sum + $arr[0]['total'];
$commsql = $sql2." where id = ".$s_commo[0]; 等于
$commsql =“select id,name,m_price,fold,v_price from tb_commo where id = $s_commo[0]“;
@$arr[0]['num'] = $s_commo[1]; 是不要报错
$sum += $arr[0]['total']; 等于 $sum =$sum + $arr[0]['total'];
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询