PHP头条
热点:

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


phpjavascript数据

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继续往底下执行?

www.phpzy.comtrue/phpyy/3032.htmlTechArticlephp-PHP一个方法根据传递值怎么执行多次? phpjavascript数据 php代码 function one($type='OfferGetAllOfferList',$start,$pagesize=10,$total=100) { $next=$start+1; if($start*$pagesize outData['next'] = $next; $this->outData['p...

相关文章

相关频道:

PHP之友评论

今天推荐