if语句跳过这一条执行下一条的语句怎么写

WBOY
Release: 2016-06-23 14:25:58
Original
2842 people have browsed it

很多条数据要写入数据库

比如if($a == 2){
         跳过这一条
               }

代码应该怎么写,知道的大哥直接给完整代码,谢谢了


回复讨论(解决方案)

if($a != 2){
         跳过这一条
               }

意思是当$a=2时这条数据不写入数据库,继续执行下一条

if($a != 2){
         执行这一条
               }

循环中 continue

if($a != 2){
   mysql_query('insert into ...');
}

如果是在循环体中的话continue就行了

foreach($xxx as $x){     if($a == 2){           continue;//如果符合这个要求,本次循环内的以下语句不再执行 开始下一次循环     }     mysql_query("xxxxxxxxxxxxxxxxxxxxxxxxxxxxx");}
Copy after login
Copy after login

foreach($xxx as $x){     if($a == 2){           continue;//如果符合这个要求,本次循环内的以下语句不再执行 开始下一次循环     }     mysql_query("xxxxxxxxxxxxxxxxxxxxxxxxxxxxx");}
Copy after login
Copy after login
++


你要的代码如下:

if($a == 2){}else{  //一堆代码}
Copy after login
Copy after login

你要的代码如下:

if($a == 2){}else{  //一堆代码}
Copy after login
Copy after login

++
留空

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template