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

while 嵌套if 无法执行

WBOY
Release: 2016-06-23 14:11:39
Original
1235 people have browsed it

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


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


回复讨论(解决方案)

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

原来如此,3q!

Related labels:
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