akio_medue 2015-09-02 07:11 采纳率: 100%
浏览 1451

PHP一个方法根据传递值怎么执行多次?

php代码

 function one($type='OfferGetAllOfferList',$start,$pagesize=10,$total=100)
    {
        $next=$start+1;
        if($start*$pagesize<=$total)
        {
            $this->outData['next'] = $next;
            $this->outData['pagesize'] = $pagesize;
            $this->outData['type'] = $type;
            $this->outData['total'] = $total;
            $this->output();
        }
        elseif($type == 'OfferGetAllOfferList' && $start*$pagesize>$total)
        {   
            $this->outData['next'] = $next;
            $this->outData['pagesize'] = $pagesize;
            $this->outData['type'] = 'TradeOrderListGet';
            $this->outData['total'] = $total;
            $this->output();
        }elseif($type == 'TradeOrderListGet' && $start*$pagesize>$total)
        {   
            $this->outData['next'] = $next;
            $this->outData['pagesize'] = $pagesize;
            $this->outData['type'] = 'MemberGet';
            $this->outData['total'] = $total;
            $this->output();
        }else
        {
            echo "同步完成";
            exit;
        }
    }



js代码

 <script>
function init(){
    $.ajax({url:"<{link ctl='member/member' act='init'}>",async:false,success: function(text,result){
        if(text == 2){
            $.ligerDialog.open({
                    height: 200,
                    url: "<{link ctl='member/member' act='one'}>",
                    width: 300,
                    name:'wintest4',
                    title:'用户初始化',
                    isResize:true,
                    buttons: [ { text: '确认', onclick: function (item, dialog) {dialog.close();}
                    },
                    { text: '关闭', onclick: function (item, dialog) {dialog.close();}}
                    ]
                });
        }else{
            notifyWarn('用户数据已同步')
        }
    }});
}

function islogin(){
    $.ajax({url:"<{link ctl='member/member' act='init'}>",async:false,success: function(text,result){
        if(text == 2){
            $.ligerDialog.warning('该用户未初始化数据,是否进行初始化?', function (type)
                {
                if(type == 'yes'){
                    init();
                }
            });
        }
        if(text == 1){
            notifyWarn('用户数据已同步')
        }
        if(text == 3){

        }
    }});
}

$(function() {
    islogin(); 
});
</script>

问题:
$type默认是OfferGetAllOfferList,当$start*$pagesize大于100时执行elseif($type == 'OfferGetAllOfferList' && $start*$pagesize>$total)里面的代码,$start归1。
$start*$pagesize大于100时执行elseif($type == 'TradeOrderListGet' && $start*$pagesize>$total)里面的代码,结果归1。
最后输出“同步完成”。
遇到的问题就是第一个if执行完怎么把$start归1继续往底下执行?

  • 写回答

1条回答 默认 最新

  • devmiao 2015-09-02 15:15
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办