Home >Backend Development >PHP Tutorial >while 嵌套if 无法执行

while 嵌套if 无法执行

WBOY
WBOYOriginal
2016-06-23 14:11:391235browse

$result = mysql_query("select title  from hello where title like '%$info%'");while($row=mysql_fetch_array($result))//通过循环读取数据内容  {    if(!$row)     {     	echo '1';     }     else     {     	echo '2';     }  }


以上语句中,只有当$row有结果的时候才会输出,就是说只会输出2,而没结果的时候,没有任何输出,即不会输出1,不知道啥原因,求解。


回复讨论(解决方案)

while($row=mysql_...
如果$row没有结果就不会进入循环体

原来如此,3q!

Statement:
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
Previous article:php数组处理Next article:array获取值。