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
    关注
    评论

报告相同问题?

悬赏问题

  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?