Home > Backend Development > PHP Tutorial > PHP查询记要只有一条

PHP查询记要只有一条

WBOY
Release: 2016-06-13 13:16:48
Original
1041 people have browsed it

PHP查询记录只有一条
本人新手:
 $sort=mysql_query("select classes_name from classes order by id");
  $classes=mysql_fetch_array($sort);
  print_r($classes).'
';
打印输出数组也只有一条记录,但是数据库中有好几条,这是这么回事?

------解决方案--------------------
无论有多少记录,一个 mysql_fetch_array 只能读取一条
------解决方案--------------------
用循环就可以多条了!!!!
------解决方案--------------------

PHP code

while($classes=mysql_fetch_array($sort)){
  print_r($classes).'<br>';
}
<br><font color="#e78608">------解决方案--------------------</font><br>while循环
<br><font color="#e78608">------解决方案--------------------</font><br>只有用循环才能输出来
<br><font color="#e78608">------解决方案--------------------</font><br>while循环输出。 <div class="clear">
                 
              
              
        
            </div>
Copy after login
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